PDA

View Full Version : Var names of MovieClips created by FOR loop


dleeinfo
10-08-2008, 03:55 AM
Hi,

If you could help me with this, that would be awesome.

Question 1:
If I use a "for" loop to create a MovieClip 4 times, what is it naming the 4 video clips? there can't be 4 var with the same names... right?
How do I assign a number or name to each created MovieClip?

Question 2:
I keep getting an error when I try to add a movie clip in the last line of the code below. could someone help me with this?

Thanks alot, -dan.

"TypeError: Error #1010: A term is undefined and has no properties.
at test45_fla::MainTimeline/frame1()"


var contain:MovieClip = new MovieClip();
var space:int = 10;
var count:int = 0;
var sun2:MovieClip = new Sun();

addChild(contain);


for (var k:int = 0; k < 3; k++) {
var ocean:MovieClip = new Ocean();
contain.addChild(ocean);
ocean.x = count * (ocean.width + space);
count++;
}

contain.ocean.addChild(sun2);

Kraka
10-08-2008, 09:59 AM
Hi dleeinfo
I think you can apply the answer mcgrail wrote me yesterday.
in "Name of an instance created by a loop?".

Good luck

dleeinfo
10-08-2008, 05:15 PM
awesome! Should've looked through the forum first...

thanks!