Hello there.
For this few days, I’ve been googling entire site i can find, and finally I can arrange this script from many sources for my button:
button_btn.addEventListener(MouseEvent.MOUSE_OVER, buttonOver);
button_btn.addEventListener(MouseEvent.ROLL_OUT, buttonOut);
function buttonOver(evet:MouseEvent):void {
animation_mc.play();
}
function buttonOut(evet:MouseEvent):void {
animation_mc.addEventListener(Event.ENTER_FRAME, reverse);
function reverse(e:Event):void {
if (animation_mc.currentFrame==1) {
animation_mc.removeEventListener(Event.ENTER_FRAME, reverse);
return;
}
animation_mc.prevFrame();
}
}
So the result for the code is:
I have a button and a MC in a stage. When I over the button, the MC is playing. When I rollout the button, it goes reverse.
And the problem is:
when I rollout the button and quickly mouse over again before the MC stop, nothing happen. The MC keep reversing. And I can only playing again if the MC animation finish reversing.
I’m trying to add statement in the code:
if (animation_mc.currentFrame==1[COLOR=Red]||something[/COLOR]) {
animation_mc.removeEventListener(Event.ENTER_FRAME, reverse);
return;
}
But I can’t figure something out to put in the code. Anyone can help? Thanks before