Re: [Flashcoders] timer question

2007-03-26 Thread Mauricio Furtado Massaia

Or u can use a setTimeout in Flash 8.

example:



function aaa():Void
{
   trace( aaa called!);
}

setTimeout( this , aaa , 1000); // 1000 milli = 1sec





or use setInterval :

var myInterval;

function aaa()
{
   trace( aaa called! )
   clearInterval( myInterval );
}

myInterval = setInterval( this , aaa , 1000 );



hugs

MauricioMassaia


On 3/23/07, Pedro Taranto [EMAIL PROTECTED] wrote:


you should use setInterval, see it in documentation

--Pedro Taranto


Gustavo Duenas escreveu:
 Hi, I'm trying to launch an event using a timer so far the code for
 trace something is this:

 var now = new Date();

 var seconds:Number = now.getSeconds();

 trace(seconds);

 var newSeconds: Number = seconds+10;

 if ( seconds == newSeconds){
 trace(plus 10);
 }

 var seconds:Number = seconds;



 the problem is that this ones doesn't trace plus 10, instead just
 traces the var seconds.

 Do you know what is wrong here?


 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


Re: [Flashcoders] timer question

2007-03-25 Thread Marc Hoffman
It doesn't trace plus 10 because you're calling it when you declare 
all your variables, rather than 10 seconds later when seconds == 
newSeconds. You'll need an onEnterFrame or other loop running to 
check, and one of the checks will have to be invoked during the 
single second when it's 10 seconds after var seconds is declared.


Marc Hoffman

At 12:28 PM 3/23/2007, you wrote:

Hi, I'm trying to launch an event using a timer so far the code for
trace something is this:

var now = new Date();

var seconds:Number = now.getSeconds();

trace(seconds);

var newSeconds: Number = seconds+10;

if ( seconds == newSeconds){
trace(plus 10);
}

var seconds:Number = seconds;



the problem is that this ones doesn't trace plus 10, instead just
traces the var seconds.

Do you know what is wrong here?


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] timer question

2007-03-25 Thread Hans Wichman

Hi,
your example is:
seconds = a;
newSeconds = a+10;
if (seconds == newSeconds)

in other words
if (seconds = seconds+10)

that will never work.

Look into setInterval and there is a undocumented setTimeout function
somewhere I think.

Better yet write your own Timer and TimerEvent class to wrap this kind of
stuff.

greetz
JC

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


Hi, I'm trying to launch an event using a timer so far the code for
trace something is this:

var now = new Date();

var seconds:Number = now.getSeconds();

trace(seconds);

var newSeconds: Number = seconds+10;

if ( seconds == newSeconds){
   trace(plus 10);
}

var seconds:Number = seconds;



the problem is that this ones doesn't trace plus 10, instead just
traces the var seconds.

Do you know what is wrong here?


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] timer question

2007-03-25 Thread eka

Hello :)

do you use the setInterval method ?

var cpt:Number = 0 ;

var action:Function = function ( msg )
{
  trace( msg ) ;
  if ( cpt ++ == 20 )
  {
  clearInterval(id) ;
  trace(stop the timer) ;
  }
}

var id = setInterval( action, 1, plus 10 seconds) ;

EKA+ :)

2007/3/23, Gustavo Duenas [EMAIL PROTECTED]:


Hi, I'm trying to launch an event using a timer so far the code for
trace something is this:

var now = new Date();

var seconds:Number = now.getSeconds();

trace(seconds);

var newSeconds: Number = seconds+10;

if ( seconds == newSeconds){
trace(plus 10);
}

var seconds:Number = seconds;



the problem is that this ones doesn't trace plus 10, instead just
traces the var seconds.

Do you know what is wrong here?


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] timer question

2007-03-25 Thread Jesse Graupmann (FILTER)
In your example, seconds doesn't really mean anything. 60 seconds plus 10 
seconds should never equal 70 seconds - you want it to equal 10 seconds.

Maybe try...

var seconds = 10;
var now = new Date();
var future = new Date();
future.setSeconds ( now.getSeconds() + seconds ); // will auto adjust the time
trace( 'now: ' + now )
trace( 'future: ' + future )
trace( 'time is up: ' + (now.getTime()  future.getTime()) )



I found it better to use Date.getTime() and work with the milliseconds, like;


//
//  TIME VERSION
//

var timeoutInterval:Number;
var seconds:Number = 3;
var now:Number = getTimer();

function startTimer ( time:Number ) {
timeoutInterval = _global.setTimeout ( this, 'onTimesUp', time * 1000 );
}

function clearTimer ( ) {
_global.clearTimeout ( timeoutInterval );
}

function onTimesUp ( ){

trace( ' \n onTimesUp \n' )

var then = now/1000;
var now = getTimer()/1000;

trace( 'TIME VERSION ::  then: ' + then + ' now: ' + now + ' = ' + 
(now-then) );


var nowD:Date = new Date( );
var timechange = futureD.getTime( ) - nowD.getTime( );

trace( 'DATE VERSION ::  timeup: ' + (timechange0) + ', ' + 
(timechange/1000) + ' seconds ago' );
}

startTimer ( seconds );



//
//  DATE VERSION
//

var nowD:Date = new Date( );
var futureD:Date = new Date ( (seconds*1000) + nowD.getTime( ) );
var timechange = futureD.getTime( ) - nowD.getTime( );

trace( 'nowD: ' + nowD );
trace( 'futureD: ' + futureD );
trace( 'timechange: ' + (timechange/1000) + ' seconds' );
trace( 'time up: ' + (timechange0) )




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gustavo Duenas
Sent: Friday, March 23, 2007 12:29 PM
To: Flashcoders mailing list
Subject: [Flashcoders] timer question

Hi, I'm trying to launch an event using a timer so far the code for
trace something is this:

var now = new Date();

var seconds:Number = now.getSeconds();

trace(seconds);

var newSeconds: Number = seconds+10;

if ( seconds == newSeconds){
trace(plus 10);
}

var seconds:Number = seconds;



the problem is that this ones doesn't trace plus 10, instead just
traces the var seconds.

Do you know what is wrong here?


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] timer question

2007-03-25 Thread Pedro Taranto

you should use setInterval, see it in documentation

--Pedro Taranto


Gustavo Duenas escreveu:
Hi, I'm trying to launch an event using a timer so far the code for 
trace something is this:


var now = new Date();

var seconds:Number = now.getSeconds();

trace(seconds);

var newSeconds: Number = seconds+10;

if ( seconds == newSeconds){
trace(plus 10);
}

var seconds:Number = seconds;



the problem is that this ones doesn't trace plus 10, instead just 
traces the var seconds.


Do you know what is wrong here?


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