Search code examples
actionscript-3flashanimationbuttonadobe

Adobe Flash. Mouse_out animation?


I have made an animation which consists in a button, when the mouse is over it, it plays a movie clip, with a stop() code at the end. But I also noticed that when the mouse leaves the button, it goes back to the "up" image (logically). I've been trying to do a mouse out animation without coding, so that when the mouse leaves the button area, it plays another movie clip. (Answers with a code are also welcome)

I also don't care if you are using actionscript 3 or 2, etc. Just let me know which one you used.


Solution

  • I think what you are wanting is an animation for a mouseOver, and an animation on mouseOut? If that is the case I would create a Movieclip and have your animation for mouseOver in frames 1-15 and you animation for the out in frames 16-30. Make sure you have a stop() in frames 1+15 to stop the MC from continually playing. Then on mouseOver call myMC.gotoAndPlay(1) and on mouseOut call myMC.gotoAndPlay(16). Hope this is what you were looking for. All the frame counts are arbitrary, you can build your animation any length you want, just make sure you change the code to match.

    mcAsButton.addEventListener(MouseEvent.MOUSE_OVER, over);
    mcAsButton.addEventListener(MouseEvent.MOUSE_OUT, out);
    
    function over(e:MouseEvent)
    {
        mcAsButton.gotoAndPlay(2)
    }
    
    function out(e:MouseEvent)
    {
    mcAsButton.gotoAndPlay(16)
    }