Search code examples
actionscript-3flashactionscriptrollover

How can I make these two things happen at same time when mouse roll over in flash


I have a movie clip called content. I want that when the mouse roll over the button, the content shows up and start playing the animation. Right now, When I mouse over, it play the movie clip, when I roll-out, it disappear which works fine. But the problem is the next time when I roll over again, nothing shows up. Any idea? Thank you in advance.

Here is my code:

code of the btn

btn.addEventListener(MouseEvent.ROLL_OVER, test);
function test(event:MouseEvent):void{
    content.visible=true;
    content.play();
}


btn.addEventListener(MouseEvent.ROLL_OUT, test2);
    function test2(event:MouseEvent):void{
    content.visible=false;
}

code for the movie clip:

Stop(); // 1st frame
Stop(); // last frame

Solution

  • You should replay your movie by using gotoAndPlay()

    function test(event:MouseEvent):void{
        content.visible=true;
        content.gotoAndPlay(1);
    }