Jenya
Jenya

Reputation: 11

AS3 for an animated button

I need help with AS3 for an animated button. The button (movie clip) I've created starts playing on a mouse-over but stops immediately when a mouse-out event occurs. But I want the button to finish the loop cycle before stopping the animation and play the animation on the next mouse-over from frame 1.

This is the code I have so far:

stop();
bt.addEventListener(MouseEvent.MOUSE_OVER,onMouseOver);
function onMouseOver(event:MouseEvent):void {
    gotoAndPlay(1);
}

Thanks in advance, Jenya

Upvotes: 1

Views: 1188

Answers (1)

Theo.T
Theo.T

Reputation: 9257

It seems you're not playing the button but the button's container actually.

Maybe try :

bt.gotoAndPlay(1)

or

(event.target as MovieClip).gotoAndPlay(1).

All you should have to do is to add a to stop() on the first frame of the button so it doesn't loop forever.

Upvotes: 1

Related Questions