Esato

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

Author FlashLite + ActionScript - Stopwatch from battery unplugged.
shdbnu
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
Joined: Mar 24, 2006
Posts: 214
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
Joined: Mar 15, 2009
Posts: > 500
From: Netherlands
PM, WWW
Posted: 2009-06-16 09:12
Reply with quoteEdit/Delete This PostPrint this post
keep trying
MMIX Newbie of the year! MonthlyShootOut
shdbnu
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
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
A hearty thank to Number1, Luhccas & Tranced for making my C702 user experience a whole lot better! <> Oh Hikaru, where are you? Monthly Cameraphone Shoot
shdbnu
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
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
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
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