Counter keeps resetting to 0 at frame one
Hello, I'm new to coding in Adobe Animate and I'm currently trying to make a counter for a simple game I'm making for goofs. Anyways the code below is what I'm using for a counter at the moment it works if there is only one frame but not if the frame goes on for more then that because if it does then the counter will reset to 0 instead of keeping the older value when it goes back to frame one in the test window. I would appreciate it a lot if anyone could tell me why this happens and if you could direct me in the right direction to solving this. Thank you so much.
extra info that might help:
- I'm using ActionScript 3.0
- The way my game is set up is that every time you click the screen it goes back to frame 1 of a graphic symbol
- I'm trying to get it where every time you hit the button or it passes frame 1 you get a point
- My code is still a work in progress so feel free to make fun of it if you wish to
//code starts below this\\
import flash.events.MouseEvent
//This is I initiated the score variable
var score:Number = 0;
//This I belive add a listen event to "Button" for when it clicks
Button.addEventListener(MouseEvent.CLICK, addPoint);
//This I belive is what makes the score apper on screen
function addPoint(event:MouseEvent)
{
scoretext.text = new String (score);
score = score + 1;
}
