-
Checking if animation has already happened in AS3.
In my project, I have an animation play on rollover, but I only want it to be able to happen once... So I want to disable the rollover code if it's already happened once (and have the mc that animated stay in it's finished state).
This is the code I currently have...
Code:
button_mc.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
function manageMouseOver(event:MouseEvent):void{
gotoAndPlay("2");
}
-
I dont think you want to handle stoping the movieclip from your button. It would be best to tell your animation to stop within its own timeline.
If your animation is in its own MovieClip, you just need to add a stop(); action on the last frame of your animation.
-
Right... Currently there is a stop on frame 1, and on the last frame.
So on rollover it goes to frame 2 and plays to the end... but currently if you rollover again, it goes back to frame 2 and replays the animation.
I want it to be locked onto that last frame if it's already been rolled over.
-
There are two ways to handle this:
1) You could just remove the event listener for the RollOver.
function manageMouseOver(event:MouseEvent):void{
gotoAndPlay("2");
button_mc.removeEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
}
2) You can create a variable and have a conditional statement
var isRolledOver:Boolean = false;
function manageMouseOver(event:MouseEvent):void{
if(isRolledOver==false){
gotoAndPlay("2");
}
isRolledOver = true;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|