Skip to main content
Participant
April 6, 2014
Answered

playing an animation and THEN moving to a scene.

  • April 6, 2014
  • 1 reply
  • 280 views

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")

}

This topic has been closed for replies.
Correct answer Ned Murphy

You need the call to the handleBackClick function to be triggered by the end of the gotoAndPlay("click") animation, not by clicking it.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
April 6, 2014

You need the call to the handleBackClick function to be triggered by the end of the gotoAndPlay("click") animation, not by clicking it.