That is one way to do it and keep poling for the var in your code, but I
find that to be a lot of trouble.  The other way is to use events and
listeners to notify the other parts of your code when the data is ready.

But the way I find most useful is to use a method sequencer.  There are
some out there that people have written, but the one I uses is Fuse.  Most
people use it to sequence scripted animation, but I use it to sequence
method calls as well.  I realize that it is another thing to learn, but it
is well documented.

There is a fuse property called "command" that allows you to pause the fuse
sequence and wait to be resumed.  Then in your function you call resume and
it goes on to the next item.

It is a great tool to sequence your code and allows you to keep it all in
one place so it is easier to read.  

Fuse:
http://www.mosessupposes.com/Fuse/

Fuse Docs:  (look at fuse >> fuse constructor >> command property)
http://www.mosessupposes.com/Fuse/fuse2.1docs/

Here is an example:

// start the loading sequence 
drawLoadManager();

function drawLoadManager(){
        trace("------------------------");
        trace("Draw Load Manager Called");
        trace("------------------------");
        var lm = this.loadManager = new Fuse();
        lm.scope = this;
        lm.push({ func:"loadXml"});
        lm.push({ command:"pause"});  
        lm.push({ func:"doSomethingWithMyXml"});
        lm.push({ command:"pause"});
        lm.push({ func:"doSomethingElse"});
        lm.start();
}

function loadXml(){
        // do all of your data loading 
        // then in your onload handler resume the fuse
        external_xml._parent = this;
        external_xml.onLoad = function(success:Boolean) {
      if (success) {
         trace(this);
         // resume the fuse sequence.
           this._parent.loadManager.resume();
      } else {
         trace("xml failed to load.");
      }
        }
}

function doSomethingWithMyXml(){
        // do something with your xml 
        // code goes here 
        // now resume the fuse and move on to the next part
        this.loadManager.resume();
        
}

function doSomethingElse(){
        // do the next thing    
        
} 



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Scott
Haneda
Sent: Thursday, November 09, 2006 4:10 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Noob, basic questions on
actionscript,withmethodology suggestions

> You tripped, exactly the way I described earlier, by accessing
> external_xml right after calling Load().  Wait until onLoad() is called
> before doing anything with external_xml.  You should trace the XML
> object inside the onLoad function:
> 
>    external_xml.onLoad = function(success:Boolean) {
>      if (success) {
>         trace(this);
>         //Do something with the XML in here.
>      } else {
>        trace("xml failed to load.");
>      }
> 
> The result will probably be "[Object object]" or something equally
> obscure, as the Flash trace routine doesn't break down complex objects
> into viewable text.
> 
> In general, you can put a flag inside the onLoad() routine that
> indicates that the XML object is safe to use.

And lets say I put a flag in there, so something like
var safe = true;

Then I go on, and need to use my XML later on in my code, if I just test
for
a basic condition of the safe variable, it may or may not be done loading.

So, how do know when it is done and you can move on, do I shove all my
future code in a repeat while safe != true or something?

Stumped....
Thanks again
-- 
-------------------------------------------------------------
Scott Haneda                                Tel: 415.898.2602
<http://www.newgeo.com>                     Novato, CA U.S.A.


_______________________________________________
[email protected]
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
_______________________________________________
[email protected]
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