Isn't using Delegate (with setInterval) one step better or are there caveats?

Steven, what I don't understand is why, if the intervals are getting
orphaned, you wouldn't have the data being pulled much MORE often
instead of less often.  I'm aware of the issues with orphaning an
interval (and just assumed that this code was in a class or was only
called once) but I don't understand the resultant behavior in relation
to what you're saying.

Michael, haven't heard from you in a while...did you work it out?

Cheers!

On 4/23/07, Steven Sacks <[EMAIL PROTECTED]> wrote:
Yes!  Always pass the scope when using setInterval.  I think it's bad
that they even included the option to not pass the scope.


David Ngo wrote:
> And to add to what Steven said, I would seriously suggest using the scope
> version of the setInterval call:
>
> var interval:Number = setInterval(this, 'myFunc', 100);
>
>
> Using setInterval this way specifies the scope object you want to call your
> method on. This also goes a long way to ensuring that your interval will
> work as you intended it to.
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks
> Sent: Monday, April 23, 2007 10:06 AM
> To: flashcoders@chattyfig.figleaf.com
> Subject: Re: [Flashcoders] setInterval woes
>
> It's debugging 101.  Eliminate the obvious things first.  Calling
> clearInterval before setInterval is a preventative measure to protect
> you from unexpected behavior from accidental orphaning of intervals. I
> ALWAYS ALWAYS ALWAYS clearInterval before I setInterval regardless of
> whether it is the first time I'm setting it.  There is no reason not to
> do it and plenty of reason to do it.
>
> If you overwrite a reference to an interval with another interval, you
> orphan that interval which continues to run in the swf until you close
> the swf and you will never be able to stop it unless you knew the id of
> the interval in question.
>
> The reason I suggested it was because his code was not well written in
> that there was no protection that the interval would be overwritten
> since it was in a frame script.  If that frame ever played again you
> would have an interval orphaned and then doubled up.  From the
> description of the behavior he gave, that's exactly what it sounded like.
>
>
>
>
> Jordan Snyder wrote:
>> Nevermind.  I'm obviously not communicating very well.  I'm extremely
>> familiar with setInterval's and setTimeout's functionality.  What I'm
>> trying to figure out is why Steven says to clearInterval first....
>> clearInterval can not be run without an argument, so I'm saying that
>> if you haven't assigned setInterval to something, what are you going
>> to call clearInterval on?  And why would you call it before it's even
>> assigned to an actual interval?
>>
>> Cheers
>>
>> On 4/20/07, David Ngo <[EMAIL PROTECTED]> wrote:
>>> Yes, that's where you're mistaken. setInterval will set an interval that
>>> will call a method at each interval. Whether you assign it to a
>>> variable or
>>> not, it will continue to call that method at each interval. This is how
>>> setInterval works. In order to clear an interval, you MUST assign an
>>> ID and
>>> call clearInterval on that ID. The functionality you're talking about
>>> is a
>>> setTimeout. That calls a method once and ONLY once after a specified
>>> delay.
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: [EMAIL PROTECTED]
>>> [mailto:[EMAIL PROTECTED] On Behalf Of Jordan
>>> Snyder
>>> Sent: Friday, April 20, 2007 3:02 PM
>>> To: flashcoders@chattyfig.figleaf.com
>>> Subject: Re: [Flashcoders] setInterval woes
>>>
>>> No, I mean that he is only calling setInterval once and has no
>>> apparent need to even assign it to a variable for use with
>>> clearInterval later.
>>>
>>> On 4/20/07, David Ngo <[EMAIL PROTECTED]> wrote:
>>>> An interval is fired at each interval. What you're talking about is a
>>>> setTimeout which is fired only once after a delay (timeout). An
>>> interval
>>> is
>>>> fired an infinite number of times until clearInterval is called.
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: [EMAIL PROTECTED]
>>>> [mailto:[EMAIL PROTECTED] On Behalf Of Jordan
>>>> Snyder
>>>> Sent: Friday, April 20, 2007 2:03 PM
>>>> To: flashcoders@chattyfig.figleaf.com
>>>> Subject: Re: [Flashcoders] setInterval woes
>>>>
>>>> Steven, why is that?  If he's only calling it once and the interval is
>>>> only defined/set once, why would you call clearInterval?
>>>>
>>>> On 4/20/07, Steven Sacks <[EMAIL PROTECTED]> wrote:
>>>>> You should always call clearInterval before setInterval.  ALWAYS.
>>>>>
>>>>>
>>>>> Michael King wrote:
>>>>>> Hey all,
>>>>>>
>>>>>> Some of you may remember my problems with visually mapping
>>> streaming
>>>> data
>>>>>> before.  I ended up needing them as separate clips to provide
>>> individual
>>>>>> roll-over support with the ability to add links in a future
>>> revision.
>>>>>> Well, now that I have it performing better, I'm breaking down the
>>>>>> information into intervals of 1 minute "bursts".  What I'm
>>> trying to
>>> do
>>>> is
>>>>>> use setInterval to have it pull the data once per minute.
>>>>>>
>>>>>> The problem is, when I use setInterval as documented, it waits the
>>> first
>>>>>> minute, does its thing, but then it ignores the interval after
>>> that,
>>>>>> pulling the data every time that frame comes up.
>>>>>>
>>>>>>
>>>>>> Here's the relevant bit of code:
>>>>>>
>>>>>> function intervalLoop() {
>>>>>>       xmlData = new XML();
>>>>>>       xmlData.load("wddx.php");
>>>>>>       xmlData.onLoad = function () {
>>>>>>             wddx = new Wddx();
>>>>>>             _root.wddxObj = wddx.deserialize(this);
>>>>>>             delete(xmlData);
>>>>>>       }
>>>>>>
>>>>>>       for (j=0; j < _root.lines.length; j++) {
>>>>>>             trace("Deleting clip: " + _root.lines[j]["pen"]._name);
>>>>>>             _root.lines[j]["pen"].removeMovieClip();
>>>>>>             delete(_root.lines[j]["pen"]);
>>>>>>             delete(_root.lines[j]["timestamp"]);
>>>>>>             _root.lines.splice(j,1);
>>>>>>       }
>>>>>>
>>>>>>       for (var i in _root.wddxObj) {
>>>>>>             _root.counter++;
>>>>>>             date_now = new Date();
>>>>>>             pen = createEmptyMovieClip("curve_" + i + "_mc", 2 +
>>>>>> _root.counter);
>>>>>>             trace("Added clip: " + pen._name);
>>>>>>             pen.lineStyle(1.5,0xFF6600);
>>>>>>             container = {pen: pen, timestamp: date_now};
>>>>>>             _root.lines.push(container);
>>>>>>             dest_long = _root.wddxObj[i]["long"];
>>>>>>             dest_lat = _root.wddxObj[i]["lat"];
>>>>>>             site = _root.wddxObj[i]["site"];
>>>>>>             src_long = _root.locations[site]["long"];
>>>>>>             src_lat = _root.locations[site]["lat"];
>>>>>>             curvePoint(pen, src_long, src_lat, dest_long,
>>> dest_lat);
>>>>>>       }
>>>>>> }
>>>>>>
>>>>>> setInterval(intervalLoop, 60000);
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>>
>>>>>> Michael King
>>>>>> CSIRT - Developer
>>>>>> Security Incident Response Group
>>>>>> Humana Inc.
>>>>>> E-mail: [EMAIL PROTECTED]
>>>>>> "STANDS: Some Theoretical Acronym Not Described Sufficiently"
>>>>>>
>>>>>> The information transmitted is intended only for the person or
>>> entity
>>> to
>>>> which it is addressed and may contain CONFIDENTIAL material.  If you
>>> receive
>>>> this material/information in error, please contact the sender and
>>> delete
>>> or
>>>> destroy the material/information.
>>>>>> _______________________________________________
>>>>>> 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
>>>>>
>>>>
>>>> --
>>>> Jordan Snyder
>>>> Applications Developer
>>>> Image Action LLC
>>>> http://www.imageaction.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
>>>>
>>>
>>> --
>>> Jordan Snyder
>>> Applications Developer
>>> Image Action LLC
>>> http://www.imageaction.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



--
Jordan Snyder
Applications Developer
Image Action LLC
http://www.imageaction.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