Loading External Images in Flash
Steps to Follow :
1. Create a folder which will have your .fla file, .swf file and your external image. Name the external image photo.jpg.
2. Create the photo and empty movie clips
- Create an empty movie clip by clicking on Insert/New Symbol. Save the symbol as empty_mc.
- Create another movie clip and save it as photo_mc. This movie clip is for any properties you would like to add to the photo, like a frame around the photo or background color etc.
- Create a frame or background in this movie clip and drop the empty movie clip (empty_mc) inside the frame.
- Give an instance name to the empty movie clip, call it empty. The external image will be loaded into this empty movie clip.
- You should have photo_mc movie clip in the the main timeline, give this an instance name of photo.
3. Actionscript for loading the external image in the photo movie clip.
- Create a new layer in your main timeline for adding the actionscript for loading the external image.
- Choose the first frame in the actionscript layer and copy the following actionscript in the actionscript panel
loadMovie("photo.jpg", photo.empty);
This script loads the image photo.jpg which is saved externally in the same folder to the empty movie clip which is in the photo movie clip (instance names empty and photo). - The script can also be added to the photo movie clip timeline if you don't want to add it to the main timeline frame. You just need to change the actionscript to
loadMovie("photo.jpg", empty);
The above script can be added in the photo_mc timeline
Congratulations! You have successfully learnt how to load external images in Flash using simple actionscript.
If the image is not loading, please check that the photo is saved as photo.jpg in the same folder and the instance names for the movie clips are correct.
Download the zip file
Please note: You need Flash 8.0 to open the .fla file.
No comments:
Post a Comment