all groups > flash actionscript > july 2004 >
You're in the

flash actionscript

group:

Creating multiple MovieClipLoader instances in a loop


Creating multiple MovieClipLoader instances in a loop Laiverd.COM
7/29/2004 11:35:45 PM
flash actionscript: Simple: how would I create multiple MovieClipLoader instances in a for loop,
each with its own listener event onLoadInit, and loadClip method etc.

Sofar I have this (which is total rubbish as I have lost track completely)

for (i = 0; i < 5; i++) {
_root.createEmptyMovieClip("container" + i, i);
// position them
_root["container" + i].x = i * 50;
_root["container" + i]._y = 50;
// create multiple MCL objects
_root[i] = new MovieClipLoader();
_root[i].loadClip("compass.jpg",_root["container" + i]);
}

I have looked at previous post in assigning for instance onRelease handlers
to buttons in a loop, but I can't find the solution there.

Thanks for any input.

John

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

Re: Creating multiple MovieClipLoader instances in a loop N Rohler
7/30/2004 1:40:23 AM
You don't need to create unique MCL instances; you check which reference is
passed to onLoadInit. The following code will do what you want:

var orig_mcl:MovieClipLoader = new MovieClipLoader();
var mcl_listener:Object = new Object();
mcl_listener.onLoadInit = function(reference_mc:MovieClip):Void {
//reference_mc will either be _root.container1, _root.container2, etc.
//do something with the mc
}
orig_mcl.addEventListener(mcl_listener);
for (i=0; i<5; i++) {
var temp_mc:MovieClip = _root.createEmptyMovieClip("container" + i, i);
temp_mc._x = i * 50;
temp_mc._y = 50;
orig_mcl.loadClip("compass.jpg", temp_mc);
}
Re: Creating multiple MovieClipLoader instances in a loop Laiverd.COM
7/30/2004 11:23:45 AM
Hey; thanks Mr. or Mrs Rohler. I'll give it a shot.

john

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

Re: Creating multiple MovieClipLoader instances in a loop Laiverd.COM
7/30/2004 10:49:47 PM
Did I say thank you? It works like a treat.

John

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

AddThis Social Bookmark Button