-
A for loop to run the same piece of code for lots of movieClips
I'm using AS3 on Flash CS4.
Instead of having this:
Actionscript Code:
DS1.stop(); DS2.stop(); DS3.stop(); DS4.stop(); DS5.stop(); DS6.stop(); DS7.stop(); DS8.stop();
I wanted to use a for loop to do it for me as I have about 100 movieClips like this that I want to stop. So I thought it I put them all into an array I could use the for loop to go through and stop them all. The code below is trying to do this but bringing up an error:
TypeError: Error #1006: value is not a function.
at railMap_fla::MainTimeline/frame1()
in the output window when I test it. But when I ran the trace it traced out each of the movieClips.
Actionscript Code:
var DepotsArray:Array = new Array (DS1,DS2,DS3,DS4,DS5,DS6,DS7,DS8);
for (var i:int=0;i<DepotsArray.length;i++){ //trace(DepotsArray[i].name); DepotsArray[i].name.stop(); }
please any help would be appreciated.
-
Originally Posted by Lizzie.Fellows
Actionscript Code:
var DepotsArray:Array = new Array (DS1,DS2,DS3,DS4,DS5,DS6,DS7,DS8);
for (var i:int=0;i<DepotsArray.length;i++){ //trace(DepotsArray[i].name); DepotsArray[i].stop(); }
please any help would be appreciated.
Lose the .name bit, the values in your arrays are direct references to the movieclips.
Cheers,
Rob
-
thanks
thats great worked like a charm
cheers mate!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|