PDA

View Full Version : How to use parameters in .onLoadInit?


kozel
06-26-2005, 10:06 AM
Hi,
my loader loads jpegs into different movie clips:
MCLoader.loadClip("picture1.jpg",first_mc);
MCLoader.loadClip("picture2.jpg",second_mc);
MCLoader.loadClip("picture3.jpg",third_mc);

is has a listener to run functions. I want to resize each picture loaded independently, I'm trying to use:

loadListener.onLoadInit = function (first_mc:movieClip) {
_width = 100;
_height = 100;
};
loadListener.onLoadInit = function (second_mc:movieClip) {
_width = 200;
_height = 200;
};
loadListener.onLoadInit = function (third_mc:movieClip) {
_width = 300;
_height = 300;
};
etc... Using the movie clip name as a parameter, but it seems to resize them all to same size! How should I tell AS which picture to resize?

Thanks

Curly Brace
06-26-2005, 11:37 AM
Try this instead:

sizes = {first_mc_x:100, first_mc_y:100, second_mc_x:200, second_mc_y:200, third_mc_x:300, third_mc_y:100};
loadListener.onLoadInit = function (my_mc:movieClip) {
my_mc._width = sizes[my_mc._name+"_x"];
my_mc._height = sizes[my_mc._name+"_y"];
};