-
Simple Counter problem
I am working on a game which needs a counter, and the counter code I found works fine, however I cannot see why at the very start instead of displaying a 0 the dynamic text box displays '_level0.counter'
I'm quite new to flash still so I'm a tad confused ^_^
heres the code:
Code:
var totalTime:Number = 0;
timer = setInterval(addTime,1000);
function addTime(){
totalTime += 1;
_root.counter = totalTime;
}
Any help would be awesome.
Kind regards,
Aravona
-
Code:
var totalTime:Number = 0;
_root.counter = totalTime;
timer = setInterval(addTime, 1000);
function addTime() {
totalTime += 1;
_root.counter = totalTime;
}
-
I only use the variable name in the textfield for debugging purposes. Best practice for Textfields (and Movieclips and Buttons) is to use an instance name. This can be done via the objects property panel.
So, give your dynamic textfield an instance name. For example myCounter. Also, change totalTime - which is reserved - for myTime.
Actionscript Code:
var myTime:Number = 0; myCounter.text = myTime;
timer = setInterval(addTime,1000);
function addTime(){ myTime += 1; myCounter.text = myTime; }
gparis
Last edited by gparis; 08-18-2010 at 09:22 AM.
Reason: Good morning, dawsonk ;)
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|