Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's possible to make returnedArray contain an array created by convertXML, but not in the way you're trying to do it. Flash simply doesn't work that way.</p> <p>This is roughly what happen when you run the code from pastebin:</p> <ol> <li>Start running function loadInformation() <ul> <li><code>var returnedArray:Array = loadinformation("http://website.com/xml.xml");</code></li> </ul></li> <li>Tell Flash that when xmlLoader loads completely, it should run LoadXML() <ul> <li><code>xmlLoader.addEventListener(Event.COMPLETE, LoadXML);</code></li> </ul></li> <li>Start loading an XML file <ul> <li><code>xmlLoader.load(new URLRequest(xmlurl));</code></li> </ul></li> <li>Tell Flash what LoadXML() is (and convertXML()) <ul> <li><code>function LoadXML(e:Event):void {...}</code></li> </ul></li> <li>Stop running function loadInformation()</li> <li>Flash goes off and does other stuff while waiting for the XML file to load</li> <li>The XML file finishes loading. Flash calls LoadXML() like it was told to. <ul> <li>Note that LoadXML() is being called by Flash, <em>not</em> by loadInformation(). </li> </ul></li> <li>LoadXML() processes the XML file.</li> </ol> <p>To get the converted array data, you need to do something like clownbaby's answer: set the value of returnedArray directly while inside LoadXML.</p> <pre><code>var returnedArray:Array; loadinformation("http://website.com/xml.xml"); function loadinformation(xmlurl:String):Array{ var xmlLoader:URLLoader = new URLLoader(); var xmlData:XML = new XML(); xmlLoader.addEventListener(Event.COMPLETE, LoadXML); xmlLoader.load(new URLRequest(xmlurl)); } function LoadXML(e:Event):void { xmlData = new XML(e.target.data); returnedArray = convertXML(xmlData); } function convertXML(xml):Array{ // Does some stuff with the XML and returns an array return rArray; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload