RE: [Flashcoders] Clear Set Interval Q:

2007-04-27 Thread Jesse Graupmann
I got to thinking... 

The problem with setting a single interval using setCurrentInterval is that
you can only have one interval running at a time, while the problem with
clearAllIntervals intervals is being forced to reset those you want to keep.


So I just wanted to share another idea, clearing all intervals EXCEPT those
you want to keep.


//
//  CLEAR ALL INTERVALS - EXCEPT
//

function clearAllIntervalsExcept ( a:Array  )
{
var x = {};
for ( var i in a ){ x [ '_' + a [ i ] ] = 1; };

// create new interval
var id = setInterval ( this, 'blank', 0 );
while ( id != 0 )
{
// count through all intervals and clear them one by one
// except those defined in the array
if ( !x [ '_' + id ] ) clearInterval ( id );
id--;
}
}

function test ()
{
trace ( arguments );
}

var _1 = setInterval ( this, 'test', 0, 1, 0 );
var _2 = setInterval ( this, 'test', 0, 2, 0 );
var _3 = setInterval ( this, 'test', 10, 3, 10 );
var _4 = setInterval ( this, 'test', 100, 4, 100 );
var _5 = setInterval ( this, 'test', 1000, 5, 1000 );

var exceptionArray = [ _4, _5 ];

clearAllIntervalsExcept ( exceptionArray ); // only _4 and _5 will run







_

Jesse Graupmann
www.jessegraupmann.com   
www.justgooddesign.com/blog/
_




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jesse
Graupmann
Sent: Thursday, April 26, 2007 9:13 PM
To: flashcoders@chattyfig.figleaf.com
Subject: RE: [Flashcoders] Clear Set Interval Q:

@ Muzak

Clearing the previous interval works as expected. I'm showing the same
example with a little more padding to illustrate how it might be better used
inside another function - the benefit being the ability to still keep track
of the most current interval id.

//
//  ONLY ONE INTERVAL
//

function setCurrentInterval () 
{
var id = setInterval.apply ( null, arguments )
clearInterval ( id - 1 );
return id;
}

function something () 
{
trace( 'something' );   
}

var id = setCurrentInterval ( this, "something", 0 )
var id = setCurrentInterval ( this, "something", 10 )
var id = setCurrentInterval ( this, "something", 100 )
var id = setCurrentInterval ( this, "something", 1000 )

trace( 'ID: ' + id );



Personally I hate intervals, and I don't mind saying that. For all the
problems they cause due to scope issues and whatnot, but unfortunately you
can't avoid them if you really care about time. So I say just clear them
all.


//
//  CLEAR ALL INTERVALS
//

function clearAllIntervals ( )
{
// create new interval
var id = setInterval ( this, 'blank', 0 );
while ( id != 0 ){
// count through all intervals and clear them one by one
clearInterval ( id )
id--
}
}
clearAllIntervals ( );



Through the course of this discussion about the never ending saga of
intervals, a few things beyond the last example stood out at me.

setInterval is probably just using 'apply' when you don't supply scope.

//
//  SCOPE TEST
//
function whoAmI ()
{
trace ( 'I am: ' + this + ' saying: ' + arguments );
}

whoAmI.apply ( this, ['Hello World'] )
whoAmI.apply ( null, ['Hola World'] )
setInterval ( whoAmI, 100, 'Goodbye World' ); 

//  I am: _level0 saying: Hello World
//  I am: undefined saying: Hola World
//  I am: undefined saying: Goodbye World



And for as often and inaccurate as they want to fire, I often think the best
solution is to check time change from the last frame to the current with
whatever method. I assumed Intervals only fired once per frame, but
apparently they fire as often and as accurate as they 'can'.

//
//ONENTERFRAME VS. SETINTERVAL
//

fTime = getTimer()
iTime = getTimer();
var frame = 0;

var id = setInterval ( this, 'onInterval', 0 );
function onInterval () {
var now = getTimer();
var change = now - iTime;
iTime = now;
trace( 'onInterval: \tf: ' + ( frame ) + '\tc: ' + change );
}

this.onEnterFrame = onFrame;
function onFrame()

{
var now = getTimer();
var change = now - fTime;
fTime = now
trace( '\nonFrame: \tf: ' + ( frame++ ) + '\tc: ' + change +
newline);
}


Re: [Flashcoders] Clear Set Interval Q:

2007-04-27 Thread Muzak
> And for as often and inaccurate as they want to fire, I often think the best
> solution is to check time change from the last frame to the current with
> whatever method. I assumed Intervals only fired once per frame, but
> apparently they fire as often and as accurate as they 'can'.
>

If I remember correcty there were some tests done when setInterval was first 
introduced and it turned out that setInterval can fire 
approx. 10 x per frame. But alot depends on what else is going on while the 
interval runs and that number may/will drop.

Oh, I now just spotted that your sample code shows those same numbers (11x per 
frame) ;-)

regards,
Muzak 


___
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] Clear Set Interval Q:

2007-04-26 Thread Jesse Graupmann
@ Muzak

Clearing the previous interval works as expected. I'm showing the same
example with a little more padding to illustrate how it might be better used
inside another function - the benefit being the ability to still keep track
of the most current interval id.

//
//  ONLY ONE INTERVAL
//

function setCurrentInterval () 
{
var id = setInterval.apply ( null, arguments )
clearInterval ( id - 1 );
return id;
}

function something () 
{
trace( 'something' );   
}

var id = setCurrentInterval ( this, "something", 0 )
var id = setCurrentInterval ( this, "something", 10 )
var id = setCurrentInterval ( this, "something", 100 )
var id = setCurrentInterval ( this, "something", 1000 )

trace( 'ID: ' + id );



Personally I hate intervals, and I don't mind saying that. For all the
problems they cause due to scope issues and whatnot, but unfortunately you
can't avoid them if you really care about time. So I say just clear them
all.


//
//  CLEAR ALL INTERVALS
//

function clearAllIntervals ( )
{
// create new interval
var id = setInterval ( this, 'blank', 0 );
while ( id != 0 ){
// count through all intervals and clear them one by one
clearInterval ( id )
id--
}
}
clearAllIntervals ( );



Through the course of this discussion about the never ending saga of
intervals, a few things beyond the last example stood out at me.

setInterval is probably just using 'apply' when you don't supply scope.

//
//  SCOPE TEST
//
function whoAmI ()
{
trace ( 'I am: ' + this + ' saying: ' + arguments );
}

whoAmI.apply ( this, ['Hello World'] )
whoAmI.apply ( null, ['Hola World'] )
setInterval ( whoAmI, 100, 'Goodbye World' ); 

//  I am: _level0 saying: Hello World
//  I am: undefined saying: Hola World
//  I am: undefined saying: Goodbye World



And for as often and inaccurate as they want to fire, I often think the best
solution is to check time change from the last frame to the current with
whatever method. I assumed Intervals only fired once per frame, but
apparently they fire as often and as accurate as they 'can'.

//
//ONENTERFRAME VS. SETINTERVAL
//

fTime = getTimer()
iTime = getTimer();
var frame = 0;

var id = setInterval ( this, 'onInterval', 0 );
function onInterval () {
var now = getTimer();
var change = now - iTime;
iTime = now;
trace( 'onInterval: \tf: ' + ( frame ) + '\tc: ' + change );
}

this.onEnterFrame = onFrame;
function onFrame()

{
var now = getTimer();
var change = now - fTime;
fTime = now
trace( '\nonFrame: \tf: ' + ( frame++ ) + '\tc: ' + change +
newline);
}

//


onFrame:f: 1c: 85

onInterval: f: 2c: 8
onInterval: f: 2c: 8
onInterval: f: 2c: 9
onInterval: f: 2c: 8
onInterval: f: 2c: 7
onInterval: f: 2c: 8
onInterval: f: 2c: 8
onInterval: f: 2c: 9
onInterval: f: 2c: 8
onInterval: f: 2c: 7
onInterval: f: 2c: 28

onFrame:f: 2c: 108

onInterval: f: 3c: 5
onInterval: f: 3c: 7
onInterval: f: 3c: 8
onInterval: f: 3c: 8
onInterval: f: 3c: 8
onInterval: f: 3c: 9
onInterval: f: 3c: 7
onInterval: f: 3c: 8
onInterval: f: 3c: 8
onInterval: f: 3c: 8
onInterval: f: 3c: 9

onFrame:f: 3c: 85




_

Jesse Graupmann
www.jessegraupmann.com  
www.justgooddesign.com/blog/   
_____




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Muzak
Sent: Wednesday, April 25, 2007 9:59 AM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Clear Set Interval Q:

I was referring to this usage:
clearInterval(setInterval(this, "something", 1000) - 1)

I'd actually have to test this (which I haven't), but it looks to me like
this will prevent 2 intervals to run at any given time.

regards,
Muzak

- Original Message - 
From: "Steven Sacks" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, April 25, 2007 6:25 PM
Subject: Re: [Flashcoders] Clear Set Interval Q:


> Danny,
>
> I think you're missing out by not using Intervals.  They're extremely
useful (and efficient) once you get familiar with them.
>
> If you'

RE: [Flashcoders] Clear Set Interval Q:

2007-04-26 Thread Karina Steffens
Here's a class I developed to manage intervals. It's not a static or
singleton, but instead should be instantiated to a variable. Can manage
multiple events and eventTypes. Most of the explanation is in the comments,
but here's an (untested) example:

 import.com.neoarchaic.util.delay;
Class MyClass {
 private var delay:Delay;
 private var delayMeId:String

 function MyClass () {
   delay = new Delay(this);
  //a target object, should have ideally been a proper class
   var target:Object = new Object();
   target.callHim = function (arg1, arg2){
  trace ("callHim "  + arg1 + " " + arg2)
   }
   //Call a function in this object, and get an id
   delayMeId = delay.doLater("callMe", 1000, "arg1", "arg2")
   //Call a function in the target object, Don't bother with id..
   delay.doLater(target, "callHim", 2000. "arg1", "arg2")
   //Call a function repeatedly. Don't bother with id..
   delay.doLoop("callMeAgain", 1000, "arg1", "arg2")
   //Interrupt the loop after 5 seconds
   delay.doLater("interruptMessage", 5000)
 }

  public function callMe(arg1, arg2){
trace ("callMe "  + arg1 + " " + arg2)
 }

 public function callMeAgain(arg1, arg2){
trace ("callMeAgain "  + arg1 + " " + arg2)
 }

 ...
 //To interrupt a specific message before execution using an id
 private function interruptMe(){
   delay.interrupt(delayMeId)
 }
 //To interrupt without an id, using the message instead
 private function interruptMessage(){
   delay.interrupt("callMeAgain")
 }
//To interrupt everything
 private function interruptAll(){
   delay.interrupt("all")
 }
}

And this is just some of what it can do. 

Cheers,
Karina



/**
 * Delay class - executes callbacks, broadcasts messages and events the
parent (or a passed target) after a set delay.
 * delay.doLater() fires an event once and then clears itself.
delay.doLoop() fires the delay interval repeatedly until interrupted.
delay.doRepeat() executes the delay n number of times before clearing
itself.
 * Each method is passed a variable number of parameters. The frist param is
an _optional_ target object that can be omitted when calling the parent
(passed to each Delay instance on creation). The second param is an event
string (ie, the name of the function to be called). The third param is the
delay. (when the target is omitted, the second and third params become first
and second).
 * delay.doRepeat()
 * Subsequent parameters are usually arguments that will be sent on to the
target with the message.
 * The dispatchEvent and broadcastMessage functions are shotrcuts of
doLater(), designed to work with a com.neoarchaic.util.AbstractBroadcaster
implementation or can be used with other implementations such as
EventDispatcher and ASBroadcaster (the broadcastMessage method is a custom
implementation of AbstractBroadcaster). To work, these methods should be
present in the parent or target object.
 * Each event (an object containing the message, type, target, etc.) is
stored in the events object and a unique id is returned to the parent. The
message execution can be interrupted & cleared at any time by calling the
interrupt() function, passing either the  event id, message, event type, or
"all".
 * Muliple events can be stored in one object, but with duplicate events
(same message, type and target), the old event will be interrupted and
cleared first.
 *
 * @author  Karina Steffens
 * @version 1.0
 * @usage
 * @class
 */
class com.neoarchaic.util.Delay {
public var parent:Object;
private var events:Object;
private var index:Number;

/**
 * Instantiate the delay.
 * A reference to the object that created the Delay instance is
stored as the parent property.
 * @param   aparent:Object
 */
function Delay (aParent:Object) {
parent = aParent;
index = 0;
events = new Object ();
}

/**Send the message to the parent after the delay - once.
 * @param   target Object
 * @param   evt String
 * @param   delay Number
 */
public function doLater ():String {
//target:Object, evt:String, delay:Number
//_global.tt ("doLater", arguments)
return storeMessage ("doLater", arguments);
}

/**Send the message to the parent after the delay - continuous.
 * @param   target Object
 * @param   evt String
 * @param   delay Number
 */
public function doLoop ():String {
return storeMessage ("doLoop", arguments);
}

/**Send the message to the parent after the delay - n times.
 * @param   target Object
 * @param   evt String
 * @param   delay Number
 * @param   times Number
 */
public function doRepeat ():String {
return storeMessage ("doRepeat", arguments);
}

/**Dispatch the event to listeners after the delay.
 * @param  

RE: [Flashcoders] Clear Set Interval Q:

2007-04-26 Thread Tom Gooding
The most sensible way to use Intervals, which are very useful - but
dangerous when not managed correctly, is to use an implementation of
TimeOut, so you fire object methods after a given delay and the API you
use for this, automatically clears up the interval. I can speak from
experience as to the annoyance of debugging code where setInterval /
clearInterval has been used irresponsibly.

Eg:


class TimeOut
{

public static function create(interval : Number, scope : Object,
method : Function, parameters : Array) : Void {
var intervalID : Number;
var timeoutFunction : Function = function() : Void {
clearInterval(intervalID);
method.apply(scope, parameters);
};
intervalID = setInterval(timeoutFunction, interval,
parameters);

}
}


Usage:

import TimeOut;

function someFunction(arg:String) : Void{
trace(arg);
}

TimeOut.create(5000,this,someFunction,["I should be called after 5
seconds"]);


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven
Sacks
Sent: 25 April 2007 17:26
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Clear Set Interval Q:

Danny,

I think you're missing out by not using Intervals.  They're extremely 
useful (and efficient) once you get familiar with them.

If you're looking for one that you don't have to keep track of, google 
"Kenny Bunch Interval Manager".  It takes care of a lot of interval 
overhead and puts all intervals in one location (namespace).

To Muzak's point, I'm able to have multiple instances of the same class 
each have their own interval running inside them.  Do you mean if you 
make the interval var static?

-Steven
___
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] Clear Set Interval Q:

2007-04-25 Thread Muzak
I was referring to this usage:
clearInterval(setInterval(this, "something", 1000) - 1)

I'd actually have to test this (which I haven't), but it looks to me like this 
will prevent 2 intervals to run at any given time.

regards,
Muzak

- Original Message - 
From: "Steven Sacks" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, April 25, 2007 6:25 PM
Subject: Re: [Flashcoders] Clear Set Interval Q:


> Danny,
>
> I think you're missing out by not using Intervals.  They're extremely useful 
> (and efficient) once you get familiar with them.
>
> If you're looking for one that you don't have to keep track of, google "Kenny 
> Bunch Interval Manager".  It takes care of a lot of 
> interval overhead and puts all intervals in one location (namespace).
>
> To Muzak's point, I'm able to have multiple instances of the same class each 
> have their own interval running inside them.  Do you 
> mean if you make the interval var static?
>
> -Steven


___
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] Clear Set Interval Q:

2007-04-25 Thread Robert Brisita

Don't know if this helps you but I'll mention it for the sake of knowledge.

You could also use:

_global.setTimeout(scope, function_str, milliseconds)

Works like setInterval and it will return an ID but it will only run 
once then kill itself.


Ciao,
Rob.

Danny Kodicek wrote:
 > > Is a new intervalID always one greater than the most recent 
  

intervalID?

AFAIK, yes.


That is, will this always work to ensure you only ever have one 
interval running at a time?
  
Again, AFAIK, yes.. but at the same time it limits your to 
only ever have one interval, no matter where.


For instance you won't be able to have 2 instances of the 
same class run an interval at the same time, which might not 
be what you're after.


If you want to manage intervals better than the built in way 
(which is non-existant), google for setInterval manager and 
I'm sure something useful will turn up.


Here's one I just found:
http://www.ny-dev.com/forums/f184/interval-manager-552/



As a general rule, I don't use them at all, but I was just interested to
find a solution that didn't involve having to keep track of all intervals in
use. When working in Director, I've in the past wrapped timeout objects (the
Lingo equivalent of intervals) in my own objects to improve the
functionality, and that's probably what I'd do in Flash too if I were to use
them.

Danny

___
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] Clear Set Interval Q:

2007-04-25 Thread Steven Sacks

Danny,

I think you're missing out by not using Intervals.  They're extremely 
useful (and efficient) once you get familiar with them.


If you're looking for one that you don't have to keep track of, google 
"Kenny Bunch Interval Manager".  It takes care of a lot of interval 
overhead and puts all intervals in one location (namespace).


To Muzak's point, I'm able to have multiple instances of the same class 
each have their own interval running inside them.  Do you mean if you 
make the interval var static?


-Steven
___
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: Re[2]: [Flashcoders] Clear Set Interval Q:

2007-04-25 Thread Danny Kodicek
 > > Is a new intervalID always one greater than the most recent 
> intervalID?
> 
> AFAIK, yes.
> 
> > That is, will this always work to ensure you only ever have one 
> > interval running at a time?
> 
> Again, AFAIK, yes.. but at the same time it limits your to 
> only ever have one interval, no matter where.
> 
> For instance you won't be able to have 2 instances of the 
> same class run an interval at the same time, which might not 
> be what you're after.
> 
> If you want to manage intervals better than the built in way 
> (which is non-existant), google for setInterval manager and 
> I'm sure something useful will turn up.
> 
> Here's one I just found:
> http://www.ny-dev.com/forums/f184/interval-manager-552/

As a general rule, I don't use them at all, but I was just interested to
find a solution that didn't involve having to keep track of all intervals in
use. When working in Director, I've in the past wrapped timeout objects (the
Lingo equivalent of intervals) in my own objects to improve the
functionality, and that's probably what I'd do in Flash too if I were to use
them.

Danny

___
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: Re[2]: [Flashcoders] Clear Set Interval Q:

2007-04-25 Thread Muzak
> Is a new intervalID always one greater than the most recent intervalID?

AFAIK, yes.

> That is, will this always work to ensure you only ever have one interval 
> running
> at a time?

Again, AFAIK, yes.. but at the same time it limits your to only ever have one 
interval, no matter where.

For instance you won't be able to have 2 instances of the same class run an 
interval at the same time, which might not be what 
you're after.

If you want to manage intervals better than the built in way (which is 
non-existant), google for setInterval manager and I'm sure 
something useful will turn up.

Here's one I just found:
http://www.ny-dev.com/forums/f184/interval-manager-552/

regards,
Muzak

- Original Message - 
From: "Danny Kodicek" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, April 25, 2007 12:02 PM
Subject: RE: Re[2]: [Flashcoders] Clear Set Interval Q:


> >
>> HG> So once you create a new interval with the same name you
>> will lose
>> HG> the path of the original?
>>
>> An interval has no name, it has a numeric ID - what has a
>> name is the variable (or more variables if you want) where
>> you store this ID. And yes, if you doesn't care about storing
>> the ID (e.g. you overwrite it), you will lose information
>> which is required for clearing a specific interval.
>

>
> clearInterval(setInterval(this, "something", 1000) - 1)
>
> Danny


___
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: Re[2]: [Flashcoders] Clear Set Interval Q:

2007-04-25 Thread Danny Kodicek
 > 
> HG> So once you create a new interval with the same name you 
> will lose 
> HG> the path of the original?
> 
> An interval has no name, it has a numeric ID - what has a 
> name is the variable (or more variables if you want) where 
> you store this ID. And yes, if you doesn't care about storing 
> the ID (e.g. you overwrite it), you will lose information 
> which is required for clearing a specific interval.

Is a new intervalID always one greater than the most recent intervalID? That
is, will this always work to ensure you only ever have one interval running
at a time?

clearInterval(setInterval(this, "something", 1000) - 1)

Danny

___
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[2]: [Flashcoders] Clear Set Interval Q:

2007-04-24 Thread R�kos Attila

HG> So once you create a new interval with the same name you will lose the path
HG> of the original?

An interval has no name, it has a numeric ID - what has a name is the
variable (or more variables if you want) where you store this ID. And
yes, if you doesn't care about storing the ID (e.g. you overwrite it),
you will lose information which is required for clearing a specific
interval.

  Attila

___
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] Clear Set Interval Q:

2007-04-24 Thread Helmut Granda

you could try

clearInterval( intervalID);
delete intervalID;

and then wait for the garbage truck to drive by and pick it up...

eric



haha, nice...
___
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] Clear Set Interval Q:

2007-04-24 Thread Helmut Granda

So once you create a new interval with the same name you will lose the path
of the original?

/*SAMPLE
Of course we know this is not the way to do it ;)
Its just for testing purposes */

var myInterval:Number = setInterval (this, "test", 1000);
var myInterval:Number = setInterval (this, "test", 1200);
var myInterval:Number = setInterval (this, "test", 1400);
var myInterval:Number = setInterval (this, "test", 1600);

clearInterval (myInterval);

function test() {
   trace("hi");
}

In this case we now don't have access to interval 1,2 and 3 and of course 4
was cleared.

...helmut

On 4/24/07, Muzak <[EMAIL PROTECTED]> wrote:


clearInterval stops an interval from executing, it doesn't remove the ID
that was assigned to the interval.

>From the docs:

setInterval:

Returns
Number - An integer that identifies the interval (the interval ID),
which you can pass to clearInterval() to cancel the
interval.


Each time you call setInterval a numeric identifier is returned, which is
auto incremented as you can see in your example.
And this also explains why it is so important to clear an interval before
creating a new one, which was mentioned a few times here
recently.

regards,
Muzak

- Original Message -
From: "Helmut Granda" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Tuesday, April 24, 2007 11:18 PM
Subject: [Flashcoders] Clear Set Interval Q:


> Is there any specific reason why after calling clearInterval the
variable
> with the interval returns 1 instead of undefined/null?
>
> Following the docs and creating a simple item we get different results
(no
> different but no what our logic might expect)
>
> function callback() {
> trace("interval called: "+getTimer()+" ms.");
> }
>
> var intervalID:Number = setInterval(callback, 1000);
> trace(intervalID);
>
> clear_btn.onRelease = function(){
> clearInterval( intervalID );
> trace(intervalID);//shouldnt this return undefined/null?
> trace("cleared interval");
> };
>
> start_btn.onRelease = function() {
>intervalID = setInterval(callback, 1000);// this adds 1 to the
current
> interval
>trace(intervalID);
> }


___
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] Clear Set Interval Q:

2007-04-24 Thread eric e. dolecki

you could try

clearInterval( intervalID);
delete intervalID;

and then wait for the garbage truck to drive by and pick it up...

eric


On 4/24/07, Steven Sacks <[EMAIL PROTECTED]> wrote:


An interval ID is just a number.  If you clear the interval, it doesn't
get rid of the number, it just stops the interval of that ID from running.

delete intervalID;



Helmut Granda wrote:
> Is there any specific reason why after calling clearInterval the
variable
> with the interval returns 1 instead of undefined/null?
>
> Following the docs and creating a simple item we get different results
(no
> different but no what our logic might expect)
>
> function callback() {
> trace("interval called: "+getTimer()+" ms.");
> }
>
> var intervalID:Number = setInterval(callback, 1000);
> trace(intervalID);
>
> clear_btn.onRelease = function(){
> clearInterval( intervalID );
> trace(intervalID);//shouldnt this return undefined/null?
> trace("cleared interval");
> };
>
> start_btn.onRelease = function() {
>intervalID = setInterval(callback, 1000);// this adds 1 to the
current
> interval
>trace(intervalID);
> }
> ___
> 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] Clear Set Interval Q:

2007-04-24 Thread Muzak
clearInterval stops an interval from executing, it doesn't remove the ID that 
was assigned to the interval.

>From the docs:

setInterval:

Returns
Number - An integer that identifies the interval (the interval ID), which 
you can pass to clearInterval() to cancel the 
interval.


Each time you call setInterval a numeric identifier is returned, which is auto 
incremented as you can see in your example.
And this also explains why it is so important to clear an interval before 
creating a new one, which was mentioned a few times here 
recently.

regards,
Muzak

- Original Message - 
From: "Helmut Granda" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" 
Sent: Tuesday, April 24, 2007 11:18 PM
Subject: [Flashcoders] Clear Set Interval Q:


> Is there any specific reason why after calling clearInterval the variable
> with the interval returns 1 instead of undefined/null?
>
> Following the docs and creating a simple item we get different results (no
> different but no what our logic might expect)
>
> function callback() {
> trace("interval called: "+getTimer()+" ms.");
> }
>
> var intervalID:Number = setInterval(callback, 1000);
> trace(intervalID);
>
> clear_btn.onRelease = function(){
> clearInterval( intervalID );
> trace(intervalID);//shouldnt this return undefined/null?
> trace("cleared interval");
> };
>
> start_btn.onRelease = function() {
>intervalID = setInterval(callback, 1000);// this adds 1 to the current
> interval
>trace(intervalID);
> } 


___
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] Clear Set Interval Q:

2007-04-24 Thread Helmut Granda

Thats what I thought. I just wanted to make sure I wasn't missing anything
else that was essential.

Thanks!

On 4/24/07, Steven Sacks <[EMAIL PROTECTED]> wrote:


An interval ID is just a number.  If you clear the interval, it doesn't
get rid of the number, it just stops the interval of that ID from running.

delete intervalID;



Helmut Granda wrote:
> Is there any specific reason why after calling clearInterval the
variable
> with the interval returns 1 instead of undefined/null?
>
> Following the docs and creating a simple item we get different results
(no
> different but no what our logic might expect)
>
> function callback() {
> trace("interval called: "+getTimer()+" ms.");
> }
>
> var intervalID:Number = setInterval(callback, 1000);
> trace(intervalID);
>
> clear_btn.onRelease = function(){
> clearInterval( intervalID );
> trace(intervalID);//shouldnt this return undefined/null?
> trace("cleared interval");
> };
>
> start_btn.onRelease = function() {
>intervalID = setInterval(callback, 1000);// this adds 1 to the
current
> interval
>trace(intervalID);
> }
> ___
> 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] Clear Set Interval Q:

2007-04-24 Thread Karina Steffens
Dunno if there's a good reason behind it, but if you need it to return null
you can always use "delete intervalID" just afar clearing the interval.

Karina

> -Original Message-
> From: Helmut Granda [mailto:[EMAIL PROTECTED] 
> Sent: 24 April 2007 22:19
> To: Flashcoders mailing list
> Subject: [Flashcoders] Clear Set Interval Q:
> 
> Is there any specific reason why after calling clearInterval 
> the variable with the interval returns 1 instead of undefined/null?
> 
> Following the docs and creating a simple item we get 
> different results (no different but no what our logic might expect)
> 
> function callback() {
>  trace("interval called: "+getTimer()+" ms."); }
> 
> var intervalID:Number = setInterval(callback, 1000); 
> trace(intervalID);
> 
> clear_btn.onRelease = function(){
>  clearInterval( intervalID );
>  trace(intervalID);//shouldnt this return undefined/null?
>  trace("cleared interval");
> };
> 
> start_btn.onRelease = function() {
> intervalID = setInterval(callback, 1000);// this adds 1 
> to the current interval
> trace(intervalID);
> }
> ___
> 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] Clear Set Interval Q:

2007-04-24 Thread Steven Sacks
An interval ID is just a number.  If you clear the interval, it doesn't 
get rid of the number, it just stops the interval of that ID from running.


delete intervalID;



Helmut Granda wrote:

Is there any specific reason why after calling clearInterval the variable
with the interval returns 1 instead of undefined/null?

Following the docs and creating a simple item we get different results (no
different but no what our logic might expect)

function callback() {
trace("interval called: "+getTimer()+" ms.");
}

var intervalID:Number = setInterval(callback, 1000);
trace(intervalID);

clear_btn.onRelease = function(){
clearInterval( intervalID );
trace(intervalID);//shouldnt this return undefined/null?
trace("cleared interval");
};

start_btn.onRelease = function() {
   intervalID = setInterval(callback, 1000);// this adds 1 to the current
interval
   trace(intervalID);
}
___
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] Clear Set Interval Q:

2007-04-24 Thread Helmut Granda

Is there any specific reason why after calling clearInterval the variable
with the interval returns 1 instead of undefined/null?

Following the docs and creating a simple item we get different results (no
different but no what our logic might expect)

function callback() {
trace("interval called: "+getTimer()+" ms.");
}

var intervalID:Number = setInterval(callback, 1000);
trace(intervalID);

clear_btn.onRelease = function(){
clearInterval( intervalID );
trace(intervalID);//shouldnt this return undefined/null?
trace("cleared interval");
};

start_btn.onRelease = function() {
   intervalID = setInterval(callback, 1000);// this adds 1 to the current
interval
   trace(intervalID);
}
___
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