PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
A for loop to run the same piece of code for lots of movieClips
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: A for loop to run the same piece of code for lots of movieClips

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    22

    Question 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.

  2. #2
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    35
    Quote Originally Posted by Lizzie.Fellows View Post
    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

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    22

    Thumbs up 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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center