Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

load image and Flash MX

Status
Not open for further replies.

raznov

Programmer
Apr 8, 2002
110
US
What is wrong with this code?



pink.onPress = function() {
loadMovie('sushi.gif', '_root.currentpict');
};



I want to load an image from a file that is in the same folder as the .swf. The target is "currentpict" which is the instance name of a movie clip (with one frame) that is located in the main timeline.

Something happens when I press the "pink" button, the movie clip "currentpict" disappears, but the image "sushi.jpg" does not take its place

kim
 
You can't load gifs that way, only jpegs! Regards,

oldman3.gif
 
yeh thanks... didn't read that anywhere... figured it out later. Where is that documented? I feel like such an idiot spending all that time.

KIM
 
From the help file:

Loading an image or sound dynamically

If you import an image or a sound while you author a Flash document, the image and sound are then packaged and stored in the SWF file when you publish the movie. To load JPEG images at runtime, you use the loadMovie or loadMovieNum method of the MovieClip object. To load MP3 sounds at runtime, you use the loadSound method of the Sound object. To return the number of bytes that have downloaded and the expected number of bytes for the image or sound file being downloaded, you use the getBytesLoaded and getBytesTotal methods of the MovieClip and Sound objects.

To load an image into a level in the Flash Player, you must use the loadMovieNum method or action. To load an image into a movie clip target in the Flash Player, you must use the loadMovie action or method. The loaded image replaces all the contents of the target movie clip.

To load a sound, you must create a new instance of the Sound object. You can use the new instance to call the loadSound method to load an event or a streaming sound. Event sounds are loaded completely before being played; streaming sounds are played as they are downloaded. You can set the isStreaming parameter of the loadSound method to specify a sound as an event sound or a streaming sound. After you load an event sound, you must call the start method of the Sound object to make the sound play. Streaming sounds begin playing when sufficient data is loaded into the movie; you don't need to use the start method.

Note: For image files, Flash supports only the standard JPEG image file type, not progressive JPEG files. For sound files, Flash supports only the MP3 sound file type.


Regards,

oldman3.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top