Copy link to clipboard
Copied
Hello everyone, i'm new to flash and i've got quite a simple question:
I've created a game. Let's say I have an instructions screen, and a game intro screen. The instructions screen has a back button that has a mouse over/click/out animation. I can get the mouse out and over functionality working, but so far all I've been able to do when CLICKING the back button is to jump directly back to game intro, without playing the click animation first. How do I play the animation, and THEN go to a scene? Thanks. Here's my code within my back button symbol:
import flash.events.MouseEvent;
backButton.addEventListener(MouseEvent.MOUSE_OVER, handleMouseOver);
backButton.addEventListener(MouseEvent.CLICK, handleMouseClick);
backButton.addEventListener(MouseEvent.MOUSE_OUT, handleMouseOut);
function handleMouseOver(e:MouseEvent){
gotoAndPlay("over")
}
function handleMouseClick(e:MouseEvent){
gotoAndPlay("click");
}
function handleMouseOut(e:MouseEvent){
gotoAndPlay("out")
}
Here's my code on the Instructions scene maintimeline:
stop();
import flash.events.MouseEvent;
backButton.addEventListener(MouseEvent.CLICK, handleBackClick)
playButton.addEventListener(MouseEvent.CLICK, handlePlayClick)
function handleBackClick(e:MouseEvent):void{
gotoAndplay(1, "Gameintro");
}
function handlePlayClick(e:MouseEvent):void{
gotoAndPlay(1, "Gameplay")
}
You need the call to the handleBackClick function to be triggered by the end of the gotoAndPlay("click") animation, not by clicking it.
Copy link to clipboard
Copied
You need the call to the handleBackClick function to be triggered by the end of the gotoAndPlay("click") animation, not by clicking it.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now