Not to step on any toes, but only to add to the information:

The XML object has a 'loaded' property inside of it which does exactly
as described in the last part of this post. It returns True if the Xml
is finished loading and ready to be referenced elsewhere.

If (myXml.loaded)
        trace(myXml.firstChild);
Else
        doTheLoadingThingieAgainOrWhatever();  

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Pete
Miller
Sent: donderdag 9 november 2006 23:33
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.
P.

>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:flashcoders- 
>> [EMAIL PROTECTED] On Behalf Of Scott Haneda
>> Sent: Thursday, November 09, 2006 5:14 PM
>> To: Flashcoders mailing list
>> Subject: Re: [Flashcoders] Noob, basic questions on actionscript, 
>> withmethodology suggestions
>> 
>> > Hi,
>> >
>> >     You will need to move external_xml.load call below the onLoad 
>> > function because your file will probably be loaded before the
handler
>> is
>> > defined (locally).
>> >
>> >     with trace(myXML) you have defined "myXML" inside the function
-
>> > this means it is not in scope outside the function.  Try:
>> >
>> >   var external_xml:XML = new XML();
>> >
>> >    //trace if loaded, or not
>> >   external_xml.onLoad = function(success:Boolean) {
>> >     if (success) {
>> > trace("xml loaded successfully.");
>> > //Do something with the XML in here.
>> >     }  else {
>> >       trace("xml failed to load.");
>> >     }
>> >  };
>> >
>> > //variable loads external XML file afterwards 
>> > external_xml.load("example1.xml");
>> >
>> > trace(external_xml);
>> 
>> I get nothing at all on the final trace, not null, not undefined,
just
>> blank.
>> --
>> -------------------------------------------------------------
>> 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
_______________________________________________
[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