'm currently making a game involving a timer and energy. Intriguing already, no? Anyway, I have two separate pieces of code controlling each element. However, when I run them at the same time, only the code for the timer works. I don’t know why this happens… I know that it isn’t the variables for each part, but something in the code. Yes, I’ve tested this extensively. Here’s some code, located in the _root timeline (I would put it in actionscript tags, but stuff is being spazz):
[FONT=Courier New][LEFT][LEFT][FONT=Verdana]var energy:Number = 100;
var generator_percent:String = Math.round(energy)+"%";
[/FONT][FONT=Courier New][FONT=Verdana]var minutes:Number = 0;
var seconds:Number = 0;
var timer:String = minutes+":"+seconds;[/FONT][/FONT]
[FONT=Verdana]//Energy code and generator_percent variable updating
onEnterFrame = function () {
generator_percent = Math.round(energy)+"%";
if (energy>0) {
energy -= 0.2;
}
};
//Timer code
onEnterFrame = function () {
seconds += 1/24;
if (seconds>59) {
seconds = 0;
minutes += 1;
}
if (seconds<=9) {
timer = minutes+":"+“0”+Math.round(seconds);
}
if (seconds>=10) {
timer = minutes+":"+Math.round(seconds);
}
};
In case it makes a difference in some way, the movie is running at 24 fps.
I can’t see any way that the timer script would stop the energy script from working, can you? If you think it would help, tell me to post all of the code for the game (I’m just showing the code I think is important). Thanks for your help.[/FONT][/LEFT]
[/LEFT]
[/FONT]