Actionscript 3: Get rid of movie clip in Array

In order to get rid of a movie clip in an Array after it is played, use the following code. This can go in the timeline as an enterframe or within a button function. Mine initiates when a button is clipped. In my flash file, movie clips are played at random and then once it is played, it is removed from the array so it can no longer be played:

//storeArray1 is my array created above this in the code. MovieClip(root) is used because
//I call this from inside a movie clip
var myNumber = Math.floor(Math.random()*MovieClip(root).storeArray1.length);
trace(“myNumber “+myNumber);
var activeCarton = MovieClip(root).storeArray1[myNumber];

//removes this element from array
MovieClip(root).storeArray1.splice(activeCarton,1);

//shows me which options are still in the array
trace (MovieClip(root).storeArray1);

Posted in Adobe Flash and tagged .

Leave a Reply