Loading image from the library

Hi everyone,

I am pretty new to Flash and am using FlashMX. My question is ‘How to you dynamically extract an image from the library onto a movie clip?’.

Thanks in advance,
Virgil Schleich
vschleich@trilliumteam.com

Make that image a movie clip and open your library and right click on it, select “Properties”. Give it a linkage Identifier, for example: image_mc. Make sure the check boxes labeled “Export for Actionscript” and “Export in the first frame” are checked, no need for “Export for runtime sharing” to be checked so just leave that alone. Then on a frame in your movie add this:
[AS]attachMovie(“image_mc”, “my_mc”, 10);
my_mc._x = 50;
my_mc._y = 50;[/AS]
image_mc - the linkage identifier
my_mc - instance name used for that movie clip when using it in Actionscript
10 - depth of the movie clip
my_mc._x - x axis location of movie clip
my_mc._y - y axis location of movie clip

If that didn’t help, reply back and I will go more into depth and maybe support a source file for you.

hey telekinesis =)

you can short the code to

this.attachMovie("image_mc", "my_mc", 10, {_x:50, _y:50});

and the option export in first frame is not necessary…
you can just drag and drop the symbol from the library onto the stage in a frame before or in the frame of the script :wink:

it may save you a future problem if you have a preloader in the movie =)

I knew about using this, but I never knew about adding the axis parameters to the action like that. Thanks, I learn a new thing all the time!

:slight_smile:

yup… you can specify any property, not only _x and _y :wink:

Thanks a bunch for the tips. :slight_smile:

:wink: =)