Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

flash 8 onEnterFrame text problem

Status
Not open for further replies.

gregrampage

Programmer
Jun 25, 2007
1
US
I'm working on a countdown and everything is working until the final command to update the dynamic text field. I'm only having this problem in a file that uses onEnterFrame:

this.onEnterFrame = function () {

var today:Date = new Date();
var currentTime = today.getTime();

var targetDate:Date = new Date(2007,5,22); //month is 0-11
var targetTime = targetDate.getTime();


var timeLeft = targetTime - currentTime;

var sec = Math.floor(timeLeft/1000);
var min = Math.floor(sec/60);
var hrs = Math.floor(min/60);
var days = Math.floor(hrs/24);

sec = string(sec % 60);
if(sec.length < 2){
sec = "0" + sec;
}

min = string(min % 60);
if(min.length < 2){
min = "0" + min;
}

hrs = string(hrs % 24);
if(hrs.length < 2){
hrs = "0" + hrs;
}
days = string(days);


var counter:String = days + ":" + hrs + ":" + min + ":" + sec;
trace(counter);
this.time_txt.text = counter;

}

////end code

the final trace statement gives me the proper 00:00:00:00 values, but it doesn't update time_txt.

Any ideas?

Thanks!

Greg
 
You could use setInterval so that the time would update like, every second or whatever.

Something like:

setInterval(myfunction, 1000);

You would have to begin your function with the proper name.
ie.

myfunction = function() {


Just an idea.
Jonathan
 
Oh you know wha - I was messing with this. For some reason it doesn't like the underscore "_" in your instance name.

Name your dynamic text box "time" and it will work.

Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top