I am coding a flash game in which the ball hits a movie clip object and this takes the user to a new scene.
this works fine but when i return back to the game scene the ball moves twice as fast.
How/Where do i reset the variables when returning to the game. See below for how i set the variables at the moment
var XSpeed:Number = 9;
var YSpeed:Number = 9;
Any help would be greatly appreciated. Thanks.
EDIT****************************************
Ok so i think i phrased this question pretty badly here is my relevant code:
var XSpeed:Number = 9; //X Speed of the Ball
var YSpeed:Number = 9; //Y Speed of the Ball
function beginCode():void{
mcPaddle.addEventListener(Event.ENTER_FRAME, movePaddle);
mcBall.addEventListener(Event.ENTER_FRAME, moveBall);
mcBall.addEventListener(Event.ENTER_FRAME, changeFrame);
}
beginCode() is then called at the end. As previously mentioned i think the problem is that the event listener already exists and is being called again each time the user returns to the page. I have tried to add an if statement to check (see comments below) but this has not worked...
Any help would be greatly appreciated. Thanks.