View Single Post
Old 02-04-2008, 06:08   #8 (permalink)
thomasvining
Senior Member
 
thomasvining's Avatar
 
Join Date: Jul 2005
Location: Tokyo
Posts: 329
Send a message via MSN to thomasvining Send a message via Skype™ to thomasvining
ok cool, thanks!

I'm working on the code, as at least have the numbers moving up now, and the hour moving once the minutes run to 60, but was wondering if there's a simpler more elegant way of doing this, and also I'm still alittle clueless as to how to add the difference in time as there is 3 variables here (hr, min, secs):

var count:Number = 0;
var num:Number = 1;
var hourNum:Number = 1;

function increase(Event)
{
count += num;
countTime();
}

function countTime()
{
var dateate = new Date();

var hourZero:String = new String();
var minuteZero:String = new String();
var secondZero:String = new String();

var h:Number = date.getHours();
var m:Number = date.getMinutes() + count;
var s:Number = date.getSeconds();

if (s < 10)
{
secondZero = "0";
}
else
{
secondZero = "";
}

if (m < 10)
{
minuteZero = "0";
}
else
{
minuteZero = "";
}

if (h < 10)
{
hourZero = "0";
}
else
{
hourZero = "";
}

if (m >= 59) {
hourNum++;
num = 1;
count = 1;
minuteZero = "0";
m = 0;
}

h = h + hourNum;

var displayCountTime:String = (hourZero + h + ":" + minuteZero + m + ":" + secondZero + s);

textCountBox.text = displayCountTime;
textCountBox.embedFonts = true;
}

stage.addEventListener(Event.ENTER_FRAME, increase);
__________________
  Reply With Quote