Author |
FlashLite + ActionScript - Stopwatch from battery unplugged. |
shdbnu Joined: Jun 16, 2009 Posts: 5 PM |
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 ] |
|
kreacher Joined: Mar 24, 2006 Posts: 254 PM |
Should the code be something like -
minutes = Math.floor(milisecondsBatteryTime / 1000 / 60 );
hours = Math.floor(minutes / 60);
minutes = minutes % 60; |
hihihans Joined: Mar 15, 2009 Posts: > 500 From: Netherlands PM |
keep trying
|
shdbnu Joined: Jun 16, 2009 Posts: 5 PM |
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? |
Lightspeed_x Joined: Mar 03, 2008 Posts: > 500 From: Dominican Republic PM |
% is the modulus operator
Xperia Z2 4.4.2 Kitkat |
shdbnu Joined: Jun 16, 2009 Posts: 5 PM |
and why don't reset? anyone knows? |
yea g Joined: Jul 02, 2008 Posts: > 500 From: New Zealand PM, WWW
|
you need to reset all the variables, not just the text label
|
shdbnu Joined: Jun 16, 2009 Posts: 5 PM |
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? |
shdbnu Joined: Jun 16, 2009 Posts: 5 PM |
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? |
|