Esato

Forum > Sony Ericsson / Sony > Themes, ringtones, screensavers, games, video clips > FlashLite + ActionScript - Stopwatch from battery unplugged.

Author FlashLite + ActionScript - Stopwatch from battery unplugged.
shdbnu
Model not set
Joined: Jun 16, 2009
Posts: 5
PM
Posted: 2009-06-16 04:33
Reply with quoteEdit/Delete This PostPrint this post
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
W995 Black
Joined: Mar 24, 2006
Posts: 254
PM
Posted: 2009-06-16 06:27
Reply with quoteEdit/Delete This PostPrint this post
Should the code be something like -
minutes = Math.floor(milisecondsBatteryTime / 1000 / 60 );
hours = Math.floor(minutes / 60);
minutes = minutes % 60;
hihihans
HTC One
Joined: Mar 15, 2009
Posts: > 500
From: Netherlands
PM
Posted: 2009-06-16 09:12
Reply with quoteEdit/Delete This PostPrint this post
keep trying
shdbnu
Model not set
Joined: Jun 16, 2009
Posts: 5
PM
Posted: 2009-06-16 15:40
Reply with quoteEdit/Delete This PostPrint this post

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
Sony Xperia Z1
Joined: Mar 03, 2008
Posts: > 500
From: Dominican Republic
PM
Posted: 2009-06-16 15:58
Reply with quoteEdit/Delete This PostPrint this post
% is the modulus operator
Xperia Z2 4.4.2 Kitkat
shdbnu
Model not set
Joined: Jun 16, 2009
Posts: 5
PM
Posted: 2009-06-16 16:48
Reply with quoteEdit/Delete This PostPrint this post
and why don't reset? anyone knows?
yea g
C905 Silver
Joined: Jul 02, 2008
Posts: > 500
From: New Zealand
PM, WWW
Posted: 2009-06-16 23:15
Reply with quoteEdit/Delete This PostPrint this post
you need to reset all the variables, not just the text label
shdbnu
Model not set
Joined: Jun 16, 2009
Posts: 5
PM
Posted: 2009-06-17 00:17
Reply with quoteEdit/Delete This PostPrint this post

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
Model not set
Joined: Jun 16, 2009
Posts: 5
PM
Posted: 2009-06-19 03:13
Reply with quoteEdit/Delete This PostPrint this post
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?
Access the forum with a mobile phone via esato.mobi