Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To load a text file (or an XML file) you can use URLLoader. Here´s an example for XML (pretty much the same) from <a href="http://www.kirupa.com/forum/showthread.php?p=1910480#post1910480" rel="nofollow noreferrer">kirupa</a></p> <pre><code>var loader:URLLoader; loader = new URLLoader(); loader.addEventListener(Event.COMPLETE, xmlLoaded); var request:URLRequest = new URLRequest("file.xml"); loader.load(request); function xmlLoaded(event:Event):void { var myXML:XML = new XML(loader.data); } </code></pre> <p>If you are calling it from another class you can pass the caller as a reference to the EventListener and handle the Event.COMPLETE from the called class:</p> <pre><code>loader.addEventListener(Event.COMPLETE, caller_class.xmlLoaded); </code></pre> <p>Ideally, you could make your loader class reusable and make it extend EventDispatcher so instead of listening the URLLoader you listen your own class. I'm not posting code for that to keep the answer simple but here´s a couple of links if you´re interested: <a href="http://www.kirupa.com/forum/showpost.php?p=2300098&amp;postcount=2" rel="nofollow noreferrer">An example for XML loader</a> and <a href="http://www.flashandmath.com/bridge/spintake2/loader.html" rel="nofollow noreferrer">Another example for a more complex image loader (to avoid confussions don´t read it unless you already understand the text/XML one)</a></p> <p>I hope it helps :)</p> <hr> <p><strong>EDITED:</strong> As apparently you're looking for the dispatchEvent way here´s a couple of tips:</p> <p>1) extend your class to EventDispatcher</p> <pre><code>public class YourClass extends EventDispatcher{ </code></pre> <p>2) use <code>dispatchEvent(new Event("event_name"));</code> to dispatch the event</p> <p>3) Listen to this event from another class. E.g.: <code>loader_class.addEventListener("event_name", callback);</code></p> <p>*4) Optionally you can change the string ("event_name") by a constant like <code>DispatcherClass.EVENT_NAME</code> by defining the constant in the dispatcher class <code>public const EVENT_NAME:String = "event_name",</code> and call it from the other class like this: <code>loader_class.addEventListener(DispatcherClass.EVENT_NAME, callback);</code></p> <p>I hope everything is clearer now. </p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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