Welcome to Esato.com




FlashLite + ActionScript - Stopwatch from battery unplugged.

Click to view updated thread with images


Posted by shdbnu
I need some help with this code...

I'm trying to do a stopwatch (HH:MM) that starts the minute I remove the charger, and resets when I put it back...
How can I do that?
My actual code don't reset and the minutes part don't back when reaches 60 minutos (like, 58, 59 then 00, 01, ...)


BatterySource = fscommand2("GetPowerSource");


if (BatterySource == 0) {
FlashTimer = getTimer();
milisecondsBatteryTime = FlashTimer;
minutesBatteryTime = Math.floor(milisecondsBatteryTime / 100 );
hoursBatteryTime = Math.floor(milisecondsBatteryTime / 1000 / 60 / 60);
minutesBatteryTimeString = (minutesBatteryTime < 10 ? "0" : "") + minutesBatteryTime;
hoursBatteryTimeString = (hoursBatteryTime < 10 ? "0" : "") + hoursBatteryTime;
BatteryTime.text = hoursBatteryTimeString + ":" + minutesBatteryTimeString;
}
else {
FlashTimer = 0;
BatteryTime.text = String("");
}
[ This Message was edited by: shdbnu on 2009-06-16 03:33 ]



Posted by kreacher
Should the code be something like -
minutes = Math.floor(milisecondsBatteryTime / 1000 / 60 );
hours = Math.floor(minutes / 60);
minutes = minutes % 60;

Posted by hihihans
keep trying

Posted by shdbnu

On 2009-06-16 06:27:51, kreacher wrote:
Should the code be something like -
minutes = Math.floor(milisecondsBatteryTime / 1000 / 60 );
hours = Math.floor(minutes / 60);
minutes = minutes % 60;


what the % does?

Posted by Lightspeed_x
% is the modulus operator

Posted by shdbnu
and why don't reset? anyone knows?

Posted by yea g
you need to reset all the variables, not just the text label

Posted by shdbnu

On 2009-06-16 23:15:03, yea g wrote:
you need to reset all the variables, not just the text label



and how I do that?

Posted by shdbnu
great, the % 60 works perfect...


now how I reset them?
I've already tried everything, every variable on that script I've tried to equals 0... and nothing...


help plz?


Click to view updated thread with images


© Esato.com - From the Esato mobile phone discussion forum