Reputation: 17
i'm working on a AS3 ball game, currently i have 2 scenes home and baseball. home has a button which sends the player to the baseball which has a little ball catching game. the button in question is on the home page, it works fine when the FLA loads and you have to click the reb button to load the game but once the game over it sends the player back to the home and the button doesnt want to load.
Upvotes: 0
Views: 31
Reputation: 3728
You'll notice that when you return to the home
scene, the output continues to trace "return". This is because you are never removing your Event.ENTER_FRAME
listener for exit
or resetting the Score
to 0.
function exit (evt:Event) : void
{
if (Score == 2)
{
Score = 0;
trace("return");
clearInterval(interval);
removeEventListener(Event.ENTER_FRAME, exit); // <--- added line
removeEventListener(Event.ENTER_FRAME,Ballgame);
gotoAndPlay(1,"home");
}
}
This will fix your issue with the button not working in your home scene, however, you'll want to add some code to clean up the display list (as it will still show all of the baseballs that you generated on the ballgame scene).
Upvotes: 1