how do i write this basic Actionscript 2 code

Discussion in 'Programming' started by visualkreations, May 25, 2009.

  1. #1
    i have 10 movie clips they are called
    bt1_mc
    bt2_mc
    bt3_mc
    bt4_mc
    bt5_mc
    bt6_mc
    bt7_mc
    bt8_mc
    bt9_mc
    bt10_mc

    i want to call all of them in one script. so something like this

    bt(123456789)_mc.gotoAndPlay(2);

    of course that's wrong but , how do i write it correctly?

    Thanks
     
    visualkreations, May 25, 2009 IP
  2. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #2
    It's been a LONG time since I have touched ActionScript, so the code sample WILL NOT work. I would create an array for the movie clips and then iterate and call the .gotoAndPlay() method. I hope that makes sense. Below is a rough code sample:

    var strClipPrefix:String = "bt";
    var arrMovieClip:Array = new Array();
    var i:Number = 0;
    
    for(i=1;i<11;i++)
    {
       arrMovieClip[i] = strClipPrefix+i; // Assign "bt1" Through "bt10" To Array
       this[arrMoveClip[i]].gotoAndPlay(2); // Call gotoAndPlay Method For Movies
    }
    Code (markup):
     
    Social.Network, May 25, 2009 IP