loki421
11-08-2009, 07:45 PM
Hi guys, I've created a very simple button and am having a little glitch.
btn.addEventListener(MouseEvent.ROLL_OVER, playUp);
btn.addEventListener(MouseEvent.ROLL_OUT, playDown);
function playUp(event:MouseEvent):void{
gotoAndPlay("fadeUp");
}
function playDown(event:MouseEvent):void{
gotoAndPlay("fadeDown");
}
Simple right? But i'm experiancing some weird behavour, when i quickly rollover and rollout it doesn't play the right movie clips.
For example, when i roll over the button a movie clip should fade up and when i roll off the movie fades out. But if i do it too quickly the movies 'swap' position if that makes sense... like the rollover fade up continues to play if i roll out before the frames finish.
What i think i need is an if statement. Something like:
btn.addEventListener(MouseEvent.ROLL_OVER, playUp);
btn.addEventListener(MouseEvent.ROLL_OUT, playDown);
function playUp(event:MouseEvent):void{
if(fadeDown is playing){
finish the fadeDown then play the fadeUp
}
else{
gotoAndPlay("fadeUp");
}
}
function playDown(event:MouseEvent):void{
if(fadeUp is playing){
finish the fadeUp then play the fadeDown
}
else{
gotoAndPlay("fadeDown");
}
}
So this should give me a smooth rollover and rollout effect no matter how quickly the mouse is moved over the button.
Can anyone just give me a nudge in the right direction with the syntax please?
Many thanks in advance all :)
btn.addEventListener(MouseEvent.ROLL_OVER, playUp);
btn.addEventListener(MouseEvent.ROLL_OUT, playDown);
function playUp(event:MouseEvent):void{
gotoAndPlay("fadeUp");
}
function playDown(event:MouseEvent):void{
gotoAndPlay("fadeDown");
}
Simple right? But i'm experiancing some weird behavour, when i quickly rollover and rollout it doesn't play the right movie clips.
For example, when i roll over the button a movie clip should fade up and when i roll off the movie fades out. But if i do it too quickly the movies 'swap' position if that makes sense... like the rollover fade up continues to play if i roll out before the frames finish.
What i think i need is an if statement. Something like:
btn.addEventListener(MouseEvent.ROLL_OVER, playUp);
btn.addEventListener(MouseEvent.ROLL_OUT, playDown);
function playUp(event:MouseEvent):void{
if(fadeDown is playing){
finish the fadeDown then play the fadeUp
}
else{
gotoAndPlay("fadeUp");
}
}
function playDown(event:MouseEvent):void{
if(fadeUp is playing){
finish the fadeUp then play the fadeDown
}
else{
gotoAndPlay("fadeDown");
}
}
So this should give me a smooth rollover and rollout effect no matter how quickly the mouse is moved over the button.
Can anyone just give me a nudge in the right direction with the syntax please?
Many thanks in advance all :)