I need help with AS3 for an animated button. The button (movie clip) I've created starts playing on a 开发者_JAVA百科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
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.
精彩评论