Hi,
you asked this question before, and I replied to it, why not continue that
thread instead of reposting it?
You are on the right track though, there are different approaches:
1. waiting a number of frames:
var curFrame:Number = 0;
var frameRate:Number = 12;
var waitFrames:Number = 20*frameRate; //wait 20 seconds

this.onEnterFrame= function (){
   curFrame++;
      if(waitFrames== curFrame){
              trace("llegamos");

      }
}

Or use setInterval:
var intervalID:Number = setInterval("myFunc", 20*1000);//set interval to 20
secs

function myFunc(){
clearInterval(intervalID);
trace("llegamos");
}

The other thing is that you have to understand why your code is wrong:
var now = getTimer(); //get milliseconds passed since swf start FOR
EXAMPLE 123541
var seconds:Number = now/1000; //seconds passed since swf start 123,541
var later:Number = seconds+20; //143,541

this.onEnterFrame= function (){
//seconds does not change, later does not change so each frame we compare
123,541 with 143,541
//even you would update seconds, the chance that seconds becomes 143,541 is
near 0.
      if(seconds == later){
trace("llegamos");

      }
}
trace(seconds);

hth,
JC


On 3/24/07, Gustavo Duenas <[EMAIL PROTECTED]> wrote:

Hi, I'm trying to set a timer to trigger a event after 20 seconds or
less, but so far i have this code, but with no results
someone help me? .
I don't know how could I got into but some help might be needed


this is the code: is inside the first frame of a movie clip and the 4
frame has: gotoAndPlay(1);


var now = getTimer();
var seconds:Number = now/1000;
var later:Number = seconds+20;
this.onEnterFrame= function (){
       if(seconds == later){
               trace("llegamos");

       }
}
trace(seconds);



Regards


Gustavo Duenas



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to