Time elapsed

Does anyone know a script that can display the time elapsed on a site like this http://www.kaos-films.com/french/index2.html , i took a look at the countdown timer tutorial but it’s not what i’m looking for …

Thanks !

couldnt you do it with a function which increments a value, beginning when the site first loads which you could then translate to a 24 clock type interface?

uuhh …
I’m just beginning with as… i totally don’t know how to do this …

Create a textfield with an instance name of timerText. Now place this code on the timeline:[AS]this.onEnterFrame = function() {
myTime = getTimer()/1000;
hours = Math.floor(myTime/3600);
minutes = Math.floor((myTime/3600-hours)*60);
seconds = Math.floor(((myTime/3600-hours)60-minutes)60);
mili = Math.floor((myTime-(seconds+(minutes
60)+(hours
3600)))*100);
myhours = (hours<10) ? “0”+hours : hours;
myseconds = (seconds<10) ? “0”+seconds : seconds;
myminutes = (minutes<10) ? “0”+minutes : minutes;
mymili = (mili<10) ? “0”+mili : mili;
timerText = myhours+":"+myminutes+":"+myseconds+":"+mymili;
};
[/AS]That should do the trick.

Hehe, that code looks semi-familiar :wink: :wink:

Have you posted that code here lost? :slight_smile:

I posted similar code during the footer content stuff… here is the part of the code that used it…

[AS]TextField.prototype.updateTimeValue = function() {
myTime = new Date();
h = myTime.getHours();
m = myTime.getMinutes();
s = myTime.getSeconds();
ms = myTime.getMilliseconds().toString();
h == 12 || h == 0 ? hours=12 : (h%12)<10 ? hours=“0”+(h%12) : hours=h%12;
m<10 ? minutes=“0”+m : minutes=m;
s<10 ? seconds=“0”+s : seconds=s;
ms.length<2 ? milliSeconds=“00”+ms : ms.length<3 ? milliSeconds=“0”+ms : milliSeconds=ms;
h<12 ? amPM=“AM” : amPM=“PM”;
this.text = hours+" . “+minutes+” . “+seconds+” . “+milliSeconds+” . "+amPM;
};[/AS]

Ahh… it have something in commom but not identical :wink:

That’s why I said semi-familiar :wink:

Ok, a little off topic, but looking at your code here lostinbeta…
[AS]
h == 12 || h == 0 ? hours=12 : (h%12)<10 ? hours=“0”+(h%12) : hours=h%12;
[/AS]
is that a “nested” Tertiary operation? I didn’t know you could do that, maybe it should be added to the Tertiary Operator tutorial. and since I’m asking about it I might as well throw this one out as well - the Tertiary operator can also do this.


a=2;
b=5;
a > b ? c=2:d=3, e=4, f=5;
trace(d); // 3
trace(e); // 4
trace(f); // 5

in the tutorial it doesn’t really show that you can give multiple statements… it might be useful. I don’t know why I thought I would mention updating the tutorial in this thread, and to someone who didn’t even write it… but, I’m going to shut up now.:x

Yes it is a nested tertiary operator

? = if

: = else

So it is basically an if/else if statement [AS]
if (h==12 || h==0) {
hours = 12;
} else if ((h%12)<10){
hours = “0”+(h%12);
} else {
hours = h%12;
}
[/AS]

Oh yeah, and for multiple statements you need parenthesis… [AS]a = 2;
b = 5;
a>b ? c=2 : (d=3, e=4, f=5);[/AS]

Hey !
Thank you guys, i just came back and see all the reply !
I’m going to see how it works !:slight_smile:

i’ve just tried your code your code Claudio and yours too lostinpanda but … i don’t see anything on the screen,
maybe i’m too stupid to use it :beam:

will try knocking something up for you when i get the chance man, till then have you put Dynamic text fields on the stage (as you will neeed em for the above)

yes, I’ve put a Dynamic text fields on the stage but …
Thanks for your help ave!
Ubik

Sorry, replace the last line for:

timerText.text = myhours+":"+myminutes+":"+myseconds+":"+mymili;

yeah !
Excellent ! thank you claudio !

Welcome :wink: