views:

17

answers:

1

I have a number of movieclips added to the stage dynamically and positioned relative to the order they were added so they make a nice list with a little space in between. I have a button on each that removes the movie clip from the stage if need. I need to run a function to loop through the remaining movieclips and re position them so they line up in a list again if one is removed. I am not sure how to achieve this though. Any ideas?

Jamie

+2  A: 

If, on creation of your movieclips, you store them in an array like:

var clipStore:Array = [ ];
for (var i:int=0; i < numClips; i++){
    var clip:MovieClip = new MovieClip();
    clipStore.push(clip);
}

later when you remove one of the objects and also it's reference in the array, you can use the array to loop through the items and update the position of each one.

var clipStoreLength:int = clipStore.length;
for (var i:int=0; i < clipStoreLength; i++){
    MovieClip(clipStoreLength[i]).y = i * (clipHeight + span);
}
dome