0
votes

I'm a relatively new user of actionscript 3 and things have been going along pretty well, but I am having difficulty finding a way to accomplish swapping movieclips in a sequential order based on their name. For example, I have a bunch of movieclips named "Guy 1", "Guy 2", "Guy 3", etc. and I am wondering what I should do to make them swap out sequentially on the clicking of a button.

I understand that I can use the removeChild and addChild functions, but I don't know how to change which children to remove and add so that each time the button is pressed, it increases by one. I am hoping to do it this way as I have at least 32 of these movieclips and I might want to add more, so I see it as the easiest way work with so many without having to manually make the button check individually for each movieclip. Any help would be greatly appreciated! Thank you!

1
Welcome to SO! Please consider reading this on how to ask good questions. In this particular case you should present a code sample demonstrating your issue.BartoszKP

1 Answers

0
votes

Just put your MovieClips into array and hold current position.

function showNext():void{
  removeChild(arrayOfClips[currentPosition]);

  if(currentPosition == arrayOfClips.length -1){
    currentPosition = 0;
  }else{
    currentPosition++;
  }

  addChild(arrayOfClips[currentPosition]);
}