Array of movie clips ActionScript 3

14,243

(untested code)

//Create array of movie clips
var someArray:Array = new Array(mc1,mc2,mc3,mc4);

//Access certain movie clip, in this case mc3
someArray[2].visible = false;

Also consider using a vector, it is generally faster.

//Declare a vector
var someVector:Vector.<MovieClip> = new Vector.<MovieClip>();
//Add movie clips
someVector.push(mc1);
someVector.push(mc2);
someVector.push(mc3);
someVector.push(mc4);

To access them I would do it like this:

var tempMC:MovieClip = someArray[1]; // or = someVector[1];
tempMC.x = 30;
tempMC.width = 300;

or you can just say:

MovieClip(someArray[1]).x = 30;

or the lazy way as shown on the 2nd line of code above.

Share:
14,243
iDomo
Author by

iDomo

Updated on June 04, 2022

Comments

  • iDomo
    iDomo almost 2 years

    How would I go about making an array of movie clips?

    If you could include an example with the setting of one part of the array, that would be great :)

  • iDomo
    iDomo over 12 years
    What if I want to access it like a movie clip, does it allow that? like setting its position?
  • iDomo
    iDomo over 12 years
    Thanks alot ;) helped me out.