Skip to main content
Participant
May 30, 2013
Answered

Access movieclips from movieclip with a loop?

  • May 30, 2013
  • 1 reply
  • 449 views

There is a moviclip under instance name of 'stadium', inside it I have 4 'log' moviclips - 'log0', 'log1',...'log3';

The thing is, that I don't know how to have access with each of them withing just one loop. Like, if I had 1000 logs inside, it's stupid to write code by hand for each of them.

My Code:

for (var i:uint =0; i<4; i++)

{

     var x:int = stadium.this["log" + i].x;

     ...

}

so of course, this gives me an error, because the way it's written is incorrect.

What is a solution for that? Thanks...

This topic has been closed for replies.
Correct answer kglad

use:

for (var i:uint =0; i<4; i++)

{

     var xvar:int = stadium["log" + i].x;

     ...

}


1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 30, 2013

use:

for (var i:uint =0; i<4; i++)

{

     var xvar:int = stadium["log" + i].x;

     ...

}


3DimitriAuthor
Participant
May 30, 2013

Thanks kglad for quick response

kglad
Community Expert
Community Expert
May 30, 2013

you're welcome.