As3 score won't stop going up
- bitcubes
-
bitcubes
- Member since: Nov. 29, 2013
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
this.addEventListener(Event.ENTER_FRAME, enterf);
function enterf(e:Event)
{
score +=1;
score_txt.text = String(score);
}
after it reaches the frame that this code is in, it keeps going up and never stops, I just want it to go up once how do I do this?
- Etherblood
-
Etherblood
- Member since: Apr. 14, 2013
- Offline.
-
- Forum Stats
- Member
- Level 12
- Game Developer
At 2/16/14 09:56 PM, bitcubes wrote: this.addEventListener(Event.ENTER_FRAME, enterf);
function enterf(e:Event)
{
score +=1;
score_txt.text = String(score);
}
after it reaches the frame that this code is in, it keeps going up and never stops, I just want it to go up once how do I do this?
The EnterFrame-Event is triggered once every frame, so if your game runs at 24 fps the function enterf will run 24 times per frame until you remove the eventListener.
if you just want to increase the score by once by 1 when entering a keyframe, the code
score +=1;
score_txt.text = String(score);
should suffice.
- Etherblood
-
Etherblood
- Member since: Apr. 14, 2013
- Offline.
-
- Forum Stats
- Member
- Level 12
- Game Developer
At 2/16/14 10:06 PM, Etherblood wrote: will run 24 times per frame until
meant 24 times per second

