This is not working because sTimer is a Number
sTimer = 0; //set var
and Numbers do not have a onEnterFrame method
sTimer.onEnterFrame = simpleTimer();
(Additionaly the '()' makes it a function call which is not
what we want
here)
As your code is probably on the timeline, i.e. inside a
MovieClip, this will
probably work:
this.onEnterFrame = simpleTimer;
For the setInterval: check out the docs, there's a good
example there.
hth
-------------
Andreas Weber
-----Original Message-----
From: flashnewbie-bounces chattyfig.figleaf.com
[mailto:flashnewbie-bounces chattyfig.figleaf.com] On
Behalf Of Paul V.
Sent: Samstag, 31. März 2007 02:52
To: Flashnewbie Mailing List
Subject: [Flashnewbie] Simple Timer -- Hmm, why is this not
working
Trying to set up a simple code, for a simple timer. I know
I should use
interval, but could anyone skim this code and tell me why it
only runs
through once. This is for simple pototype program, and I
don't want to
start building the whole prog. Just to do some testing.
Right now it will
be simple alpha fade-ins, that are just running in sequence.
(More latter).
Thanks,
//here is the code
sTimer = 0; //set var
init(); //call initial function
function init(){
sTimer.onEnterFrame = simpleTimer();
//set sTimer var to call simpleTimer ever time it hits a
new frame 25
frames per second. }
function simpleTimer(){
sTimer += 1;
//increment sTimer var. For some reason it is only
running through this
once.
trace(sTimer);} //trace result " 1 ".
stop.
/*
if(sTimer > 1000 && sTimer < 1001){ doThis();}
//sedo code
if(sTimer > 1100 && sTimer < 1101){
doThis2();}
if(sTimer > 1200 && sTimer < 1201){
doThis3();}
if(sTimer > 1300 && sTimer < 1301){
doThis4();}
if(sTimer > 1400 && sTimer < 1401){
doThis5();}
*/
//not it is only running through once
Thanks for any tips, or even better fixes. (and if anyone
knows of a walk
through and or tutorial on how to use the setInterval and
clearInterval
functions, that would be great as well.
Many Thank you to you guys, and gals(?).
Paul Vdst
_______________________________________________
Flashnewbie chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.c
om
_______________________________________________
Flashnewbie chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
|