Search code examples
actionscript-3flash

On AS3, how go to a specific frame inside multiple movie clips


Hello experienced people, I´m working on a dress up game on AS3. I need to made a button that removes all clothing.

Over the body base, in the main scene, there´s multiple movie clips for each clothing part (ShirtsMC, PantsMC, ShoesMC, etc) inside every MC there´s frames with clothing but there´s always an empty frame See picture to simulate a removed item.

Each MC has a different number of items, and my question is how/if can this be done, when press that "RemoveAllClothing" button it commands the multiple movie clips to go at that empty frame in each one of the multiple MC.

I´m not really sure how archive this, any help will be greatly appreciated

-Freefox-


Solution

  • Add an empty frame (last frame) to all your objects. When a button is clicked, set your movie clips to last frame (empty).

    removeAllClothing.addEventListener(MouseEvent.CLICK, removeIt);
    
    function removeIt(e:MouseEvent):void
    {
       ShirtsMC.gotoAndStop(ShirtsMC.totalFrames);
       PantsMC.gotoAndStop(PantsMC.totalFrames);
       ShoesMC.gotoAndStop(ShoesMC.totalFrames);
    }