This content has been marked as final. Show 7 replies
the easiest method I know of is to place a .jpg in a movie and publish it as a .swf then the loadmovie command will work.
one more thing ...if you make the movie that the .jpg is placed the same size as the movie it is loading into, then you can place the .jpg where you want it to appear and it will register that position when loaded.
Your dynamically created movieclips will appear ontop of eveything on the stage unless you use a specific negative depth. I can't rmemeber the number off the top of my head but it exists. A little more subtle way to do this is to place an empty movieclip on a layer that is below all the elements you want your image to be behind. Then just load your JPG into that movieclip instaed of creating an empty clip dynamically.
> the easiest method I know of is to place a .jpg in a movie
> and publish it as a .swf then the loadmovie command will
Both the loadMovie() function and the MovieClip.loadMovie() method load
JPGs just fine. Since the release of Flash 8, it's even possible to
load GIFs and PNGs, too.
>> My top layer "Actions" contains all my ActionScript code.
>> in this layer I am creating an empty movie clip using the
>> createEmptyMovieClip() method and then attempting to
>> load a JPG using the loadMovie() method.
As it turns out, there is no ActionScript equivalent to layers. There
are depths, which *roughly* correlate to layers -- depths pertain to a given
timeline, but it doesn't get deeper than that.
>> I want the JPG to appear "behind" other images in the
>> movie clip (i.e a lower layer). I'm assuming that I should
>> accomplish this by passing a certain depth in the
>> createEmptyMovieClip() method.
Anything you load or create dynamically will appear above assets you
drag to the Stage by hand. You could arrange your manual content into one
movie clip and load your JPG into another, then invoke
MovieClip.swapDepths() to swap their depths.
>> My understanding is that a higher depth value means the
>> movie clip will be created on a higher layer (more "in
>> front"), but I can't seem to use this value to affect where
>> the image ends up when loaded.
Yeah ... it really does seem like layers *should* correspond to depths,
but it just doesn't work that way. I *believe* that layers are located at a
reserved depth (possibly negative numbers).
stiller (at) quip (dot) net
Dev essays: http://www.quip.net/blog/
"Luck is the residue of good design."
the mc you placed on stage actually have negative value for depth in thousands.
try the getDepth and see for yourself.
there's a depth manager class that allow you to manage.
however, a quick and easy way to manage the depth with using another class...
in your layer, put an empty movie clip in there, you have to create an empty one like mcBlank
then name the instance jpg_mc
place is in the layer you want,
and at run time, you can use loadMovie("mypic.jpg",jpg_mc);
Thanks for the advice nice multimedia. However, I don't think that creating an SWF for each JPG that I want to load will be feasible since I have many of them and will be changing them frequently via an XML control file. I'm doing this so that I can change the images loaded without having to go into Flash and re-publish, so having to generate an SWF file everytime I have a new image would probably defeat that purpose. Thanks again though for the quick response!
Shyaway, David and Tim,
Thanks a ton guys! Especially David for taking the time to explain some of the nuts and bolts.
Although I don't totally understand what a depth is now (I'll read up on it though), I understand that this doesn't simply correspond to the layer on the timeline like I originally thought.
It seems that the best way to handle this will be to "manually" add a movie clip and then load it there.