Groups | Blog | Home
all groups > flash (macromedia) > august 2004 >

flash (macromedia) : TImer


TomEnokR
8/7/2004 11:29:15 PM
I want to create a simple timer that includes:

1. Start button that starts the timer.
2. Stop button that stops the timer.
3. Reset button that resets the timer.
4. text or combobox that associates the time with a task.

Mostly I just need the 'timer' functionality. Anyone have any code that can
help?

-Shaun
TomEnokR
8/8/2004 3:20:39 AM
....at any rate...

Thank you for the code.

urami_
8/8/2004 10:35:57 AM


[quoted text, click to view]

Make dyn. text field with vars name "timeDisplay"
Than make Start, Stop , Reset Buttons.
Place all in movie clip and to that movie clip attach the following action :

// on the movieclip
onClipEvent (load) {
function start() {
d = new Date();
t0 = getTimer();
method = run;
}
function run() {
d.setTime(getTimer()-t0);
var h = d.getUTCHours();
if (h<10) {
H = "0"+h;
}
var m = d.getUTCMinutes();
if (m<10) {
m = "0"+m;
}
var s = d.getUTCSeconds();
if (s<10) {
s = "0"+s;
}
var ms = d.getUTCMilliSeconds();
if (ms<100) {
ms = "0"+ms;
}
if (ms<10) {
ms = "0"+ms;
}
timeDisplay = h+" : "+m+" : "+s+" : "+ms;
}
}
onClipEvent (enterFrame) {
method();
}

Than back to buttons and , to Start button ad :

on (press) {
if (!running) {
method = start;
running = true;
}
}

to Stop :

on (press) {
method = null;
running = false;
}

to Reset

on (press) {
method = null;
timeDisplay = rapTime="";
running = false;
}


Pretty much it.

http://www.flashfugitive.com/ang-zhang/stopWatch/
d/l
http://www.flashfugitive.com/ang-zhang/stopWatch/stopwatch.zip



--


Regards


urami_*

<hol>
http://flashfugitive.com/
</hol>


By The way:
If you try to mail me , DO NOT *laugh*
urami_
8/8/2004 11:01:26 AM
[quoted text, click to view]
.................


Sorry, forgot our arrangement and forgot to add you to my ignore list.
I answer threads by order they come , did not realize the sends ID.
You can scrub the reply, wait for someone else to find time to entertain you.
AddThis Social Bookmark Button