What I would highly recommend is externalizing your interval and data
loading into a class. This way, you have the class handle its own state and
data, fire an event once it's loaded or reloaded data and have your movie
listen for that event. The class can then be instantiated just once at the
beginning of your movie. OR, use a Singleton to ensure a single
instantiation. I would probably advise against the Singleton approach for
your purposes, though.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael King
Sent: Friday, April 20, 2007 5:35 AM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] setInterval woes


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

Reply via email to