Re: [Flashcoders] setting a timer in flash 8

2007-03-27 Thread Omar Fouad

I created a Class called SetTimer it lets you call a function after a
specified time in second... And setting how many times the function is
executed with the given interval If you are interested tell me...

On 3/27/07, Gustavo Duenas [EMAIL PROTECTED] wrote:


thanks to all of you guys..now I did it and I've just trigger an
event using the time.
  thanks to all.


Gustavo Duenas
On Mar 26, 2007, at 4:24 PM, Joe Wheeler wrote:

 Don't forget to clear the interval inside the function you call -
 otherwise
 it will repeat on and on. It's also best practice to clear an interval
 before you set it (in case it gets set twice).

 If you only want the function called once you can also use
 _global.setTimeout( func, time ).

 J

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of
 Parvaiz
 Patel
 Sent: 26 March 2007 13:51
 To: flashcoders@chattyfig.figleaf.com
 Subject: RE: [Flashcoders] setting a timer in flash 8

 Hi Gustave,

 Here is the answer to your query.

 The best way for any timing related task is to use Interval.

 Here is the syntax:
 var variable name:Number = setInterval(function name to call,
 time
 interval in millisecond);

 function function name to call(){

 //do your task here..

 }

 

 The following is the example for your inderstanding  testing.



 this.createTextField(date_txt, this.getNextHighestDepth(), 10,
 10, 100,
 22); date_txt.autoSize = true; date_txt.selectable = true;

 var date_interval:Number = setInterval(updateTime, 500, date_txt);

 function updateTime(my_txt:TextField) {
 my_txt.text = new Date().toString(); trace(my_txt.text); }


 I hope, this is well enough to solve your problem.

 Thanks  regards,

 Parvaiz Patel.




 Gustavo Duenas 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



 ___
 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

 ___
 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





--
Omar Fouad - Digital Emotions...

Love is always patient and kind. It is never jealous. Love is never boastful
nor conceited It is never rude or selfish. It does not take offense and is
not resentful. Love takes no pleasure in other people's sins...but delights
in the truth. It is always ready to excuse, to trust, to hope... and to
endure... whatever comes.
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought

RE: [Flashcoders] setting a timer in flash 8

2007-03-26 Thread Parvaiz Patel
Hi Gustave,
 
Here is the answer to your query.
 
The best way for any timing related task is to use Interval.
 
Here is the syntax:
var variable name:Number = setInterval(function name to call, time
interval in millisecond);
 
function function name to call(){
 
//do your task here..
 
}
 

 
The following is the example for your inderstanding  testing.
 
 
 
this.createTextField(date_txt, this.getNextHighestDepth(), 10, 10,
100, 22);
date_txt.autoSize = true;
date_txt.selectable = true;
 
var date_interval:Number = setInterval(updateTime, 500, date_txt);
 
function updateTime(my_txt:TextField) {
my_txt.text = new Date().toString();
trace(my_txt.text);
}
 
 
I hope, this is well enough to solve your problem.
 
Thanks  regards,
 
Parvaiz Patel.  
 
 
 
 
 Gustavo Duenas 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



___
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


RE: [Flashcoders] setting a timer in flash 8

2007-03-26 Thread Joe Wheeler
Don't forget to clear the interval inside the function you call - otherwise
it will repeat on and on. It's also best practice to clear an interval
before you set it (in case it gets set twice). 

If you only want the function called once you can also use
_global.setTimeout( func, time ).

J

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Parvaiz
Patel
Sent: 26 March 2007 13:51
To: flashcoders@chattyfig.figleaf.com
Subject: RE: [Flashcoders] setting a timer in flash 8

Hi Gustave,
 
Here is the answer to your query.
 
The best way for any timing related task is to use Interval.
 
Here is the syntax:
var variable name:Number = setInterval(function name to call, time
interval in millisecond);
 
function function name to call(){
 
//do your task here..
 
}
 

 
The following is the example for your inderstanding  testing.
 
 
 
this.createTextField(date_txt, this.getNextHighestDepth(), 10, 10, 100,
22); date_txt.autoSize = true; date_txt.selectable = true;
 
var date_interval:Number = setInterval(updateTime, 500, date_txt);
 
function updateTime(my_txt:TextField) {
my_txt.text = new Date().toString(); trace(my_txt.text); }
 
 
I hope, this is well enough to solve your problem.
 
Thanks  regards,
 
Parvaiz Patel.  
 
 
 
 
 Gustavo Duenas 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



___
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

___
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


Re: [Flashcoders] setting a timer in flash 8

2007-03-26 Thread Gustavo Duenas
thanks to all of you guys..now I did it and I've just trigger an  
event using the time.

  thanks to all.


Gustavo Duenas
On Mar 26, 2007, at 4:24 PM, Joe Wheeler wrote:

Don't forget to clear the interval inside the function you call -  
otherwise

it will repeat on and on. It's also best practice to clear an interval
before you set it (in case it gets set twice).

If you only want the function called once you can also use
_global.setTimeout( func, time ).

J

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of  
Parvaiz

Patel
Sent: 26 March 2007 13:51
To: flashcoders@chattyfig.figleaf.com
Subject: RE: [Flashcoders] setting a timer in flash 8

Hi Gustave,

Here is the answer to your query.

The best way for any timing related task is to use Interval.

Here is the syntax:
var variable name:Number = setInterval(function name to call,  
time

interval in millisecond);

function function name to call(){

//do your task here..

}



The following is the example for your inderstanding  testing.



this.createTextField(date_txt, this.getNextHighestDepth(), 10,  
10, 100,

22); date_txt.autoSize = true; date_txt.selectable = true;

var date_interval:Number = setInterval(updateTime, 500, date_txt);

function updateTime(my_txt:TextField) {
my_txt.text = new Date().toString(); trace(my_txt.text); }


I hope, this is well enough to solve your problem.

Thanks  regards,

Parvaiz Patel.





Gustavo Duenas 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




___
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

___
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


Re: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Shahid Kanwal
hi,

i think this might help with the flash timer 

stop();
pausedAt = getTimer();
this.createEmptyMovieClip(frameLoop, 1);
frameLoop.onEnterFrame = function() {
if ((getTimer()-pausedAt)/500=6) {
play();
this.removeMovieClip();
}
// end if  
};

I have used this many times.


Shahid


 
-
Now that's room service! Choose from over 150,000 hotels 
in 45,000 destinations on Yahoo! Travel to find your fit.
___
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


Re: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Pedro Taranto

var intervalID:Number = setInterval(timer, 1000, this);
var timeLimit:Number = 20;
var timeCounter:number = 0;

function timer( mc:MovieClip )
{
   if( mc.timeCounter == mc.timeLimit )
   {
  mc.timeLimit = 0;
  clearInterval(mc.IntervalID);
   trace(time LIMIT);
   }
   else
   {
  mc.timeCounter++;
  trace(time: +mc.timeCounter);
   }
}

--Pedro Taranto

Gustavo Duenas escreveu:
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


Re: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Hans Wichman

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


Re: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Alain Rousseau


I made a Timer class that I use for another set of Classes I wrote. Here 
is the class itself, it's pretty precise and reliable so far. Hope it 
Helps !


usage :

import ca.daroost.utils.Timer;
soundTimer = new Timer();
soundTimer.addEventListener(onTimerDone, this);
soundTimer.addEventListener(onTimerStart, this);

soundTimer.startTimer(0, 2000); // 2 second timer

function onTimerDone(evtObj:Object) {
   trace(Timer is done after +evtObj.delta+ms   - wanted time is : 
+evtObj.timerDelta+ms);

}

function onTimerStart(evtObj:Object) {
   trace(Timer has started);
}

 Class Start ---

import mx.events.EventDispatcher;
import mx.utils.Delegate;

class ca.daroost.utils.Timer {
// Constants:
   public static var CLASS_REF = ca.daroost.utils.Timer;
// Public Properties:
   public var dispatchEvent:Function;
   public var addEventListener:Function;
   public var removeEventListener:Function;
// Private Properties:
   private var tEnd:Number;
   private var tStart:Number; // usually this is 0, but in case of a 
sound loop there could be a start offset
   private var _starttime:Number; // actual timer start value set with 
getTimer()

   private var tDelta:Number; // Delta time between tEnd and tStart
   private var tInterval:Number;
// Initialization:
   public function Timer(startTime:Number,endTime:Number) {
   EventDispatcher.initialize(this);
   tStart = (startTime != undefined) ? startTime : 0;
   tEnd = (endTime != undefined) ? endTime : 0;
   tDelta = 0;
   tInterval = 0;
   }

// Public Methods:
   public function startTimer(startTime:Number,endTime:Number) {
   tEnd = endTime;
   tStart = startTime;
   tDelta = tEnd - tStart;
   _starttime = getTimer();
   tInterval = setInterval(this, updateTimer, 1);
   this.dispatchEvent({target:this, type:onTimerStart, 
startTime:tStart, endTime:tEnd});

   }
  
   public function set endTime(value:Number):Void {

   tEnd = value;
   }
  
   public function get endTime():Number {

   return tEnd;
   }
  
   public function set startTime(value:Number):Void {

   tStart = value;
   }
  
   public function get startTime():Number {

   return tStart;
   }
// Semi-Private Methods:
// Private Methods:
   private function updateTimer():Void {
   var _delta:Number;
   _delta = getTimer() - _starttime;
   if (_delta = tDelta -50) {
   // here we will get a more precise value with the last 50 ms
   while (_delta  tDelta) {
   _delta = getTimer() - _starttime;
   }
   this.dispatchEvent({target:this, type:onTimerDone, 
delta:_delta, timerDelta:tDelta});

   clearInterval(tInterval);
  
   }

   }

}


 Class End---

Gustavo Duenas 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


Re: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Yehia Shouman

try using undocumented setTimeOut or setInterval instead


say you have a function foo
with setInterval:

var secondsToWait:Number= 20*1000 //20 seconds
var interval_ID:Number=setInterval(this,foo,2)

function foo()
{
clearInterval(interval_ID);
trace(llegamos con setInterval);
}

with setTimeOut

setTimeout(this,foo,1000)
function foo()
{
  trace(llegamos con setTimeOut);
}

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





--
Yehia Shouman
___
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


RE: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Glenn Grant
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


RE: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Jesse Graupmann
Time is never exact because frame rate is independent from time. Just check
if it's greater or equal to the time you desired.


var now = getTimer();
var waitSeconds = 3;
var later:Number = now + ( waitSeconds * 1000 );

this.onEnterFrame= function ()
{
var now = getTimer();
if( now = later)
{
trace( now );
delete this.onEnterFrame;
}
else
{
var countdown = ( later - now );
trace( wait for it :  + countdown );
}
}



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gustavo
Duenas
Sent: Friday, March 23, 2007 4:58 PM
To: Flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] setting a timer in flash 8

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


RE: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Keith Reinfeld
Gustavo, 
 
stop(); 
var later:Number = (getTimer()/1000) + 20; 
this.onEnterFrame = function (){ 
var now:Number = getTimer()/1000; 
if(now = later){ 
trace(llegamos); 
delete this.onEnterFrame; 
} 
} 
trace(later); 
 
HTH 
 
-Keith 
http://keithreinfeld.home.comcast.net
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gustavo
Duenas
Sent: Friday, March 23, 2007 6:58 PM
To: Flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] setting a timer in flash 8

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


Re: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Helmut Granda

Gustavo,

Duenas noches :)

Search for setInterval in the help manual ;).

...helmut

On 3/23/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


Re: [Flashcoders] setting a timer in flash 8

2007-03-25 Thread Alain Rousseau
Btw when setting a start time other than 0 to the timer, it's the 
difference between both that will be calculated.

Example :

you app starts at 0ms, but for some reason you need some data loaded 
that your timer needs before it starts. You need to take into account 
the time elapsed.


var wantedEnd:Number = 2000;
var curTime:Number = getTimer();
soundTimer.startTimer(curTime, wantedEnd);

the Timer won't go for 2 seconds, but an event will be triggerred after 
2 seconds of the Application launch.


HTH

Alain Rousseau wrote:


I made a Timer class that I use for another set of Classes I wrote. 
Here is the class itself, it's pretty precise and reliable so far. 
Hope it Helps !


usage :

import ca.daroost.utils.Timer;
soundTimer = new Timer();
soundTimer.addEventListener(onTimerDone, this);
soundTimer.addEventListener(onTimerStart, this);

soundTimer.startTimer(0, 2000); // 2 second timer

function onTimerDone(evtObj:Object) {
   trace(Timer is done after +evtObj.delta+ms   - wanted time is : 
+evtObj.timerDelta+ms);

}

function onTimerStart(evtObj:Object) {
   trace(Timer has started);
}

 Class Start ---

import mx.events.EventDispatcher;
import mx.utils.Delegate;

class ca.daroost.utils.Timer {
// Constants:
   public static var CLASS_REF = ca.daroost.utils.Timer;
// Public Properties:
   public var dispatchEvent:Function;
   public var addEventListener:Function;
   public var removeEventListener:Function;
// Private Properties:
   private var tEnd:Number;
   private var tStart:Number; // usually this is 0, but in case of a 
sound loop there could be a start offset
   private var _starttime:Number; // actual timer start value set with 
getTimer()

   private var tDelta:Number; // Delta time between tEnd and tStart
   private var tInterval:Number;
// Initialization:
   public function Timer(startTime:Number,endTime:Number) {
   EventDispatcher.initialize(this);
   tStart = (startTime != undefined) ? startTime : 0;
   tEnd = (endTime != undefined) ? endTime : 0;
   tDelta = 0;
   tInterval = 0;
   }

// Public Methods:
   public function startTimer(startTime:Number,endTime:Number) {
   tEnd = endTime;
   tStart = startTime;
   tDelta = tEnd - tStart;
   _starttime = getTimer();
   tInterval = setInterval(this, updateTimer, 1);
   this.dispatchEvent({target:this, type:onTimerStart, 
startTime:tStart, endTime:tEnd});

   }
 public function set endTime(value:Number):Void {
   tEnd = value;
   }
 public function get endTime():Number {
   return tEnd;
   }
 public function set startTime(value:Number):Void {
   tStart = value;
   }
 public function get startTime():Number {
   return tStart;
   }
// Semi-Private Methods:
// Private Methods:
   private function updateTimer():Void {
   var _delta:Number;
   _delta = getTimer() - _starttime;
   if (_delta = tDelta -50) {
   // here we will get a more precise value with the last 50 ms
   while (_delta  tDelta) {
   _delta = getTimer() - _starttime;
   }
   this.dispatchEvent({target:this, type:onTimerDone, 
delta:_delta, timerDelta:tDelta});

   clearInterval(tInterval);
 }
   }

}


 Class End---

Gustavo Duenas 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




___
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] setting a timer in flash 8

2007-03-24 Thread Gustavo Duenas
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