hi gustavo,

your first problem is that you have a gotoAndPlay loop. that means that
every time you go back to frame 1 you are re-creating your now variable, so
it is never going to have a chance to get bigger. secondly, the timer does
need to be updated & checked inside your onEnterFrame (i used a
setInterval), so that it can be compared with your later variable. try this:

stop();
var startTime:Number = getTimer()/1000;
var later:Number = 20;
var timeCheck:Number = setInterval(checkTime, 100);
function checkTime(){
        var currentTime:Number = getTimer()/1000;
        var elapsedTime:Number = currentTime - startTime;
        if(elapsedTime >= later){
                trace("llegamos");
                clearInterval(timeCheck);
        }
}


Message: 22
Date: Fri, 23 Mar 2007 19:57:54 -0400
From: Gustavo Duenas <[EMAIL PROTECTED]>
Subject: [Flashcoders] setting a timer in flash 8
To: Flashcoders@chattyfig.figleaf.com
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

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

_______________________________________________
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