Skip to content


[AS 3] Loading an External XML File with Actionscript

This snippett of code will just load in the xml document and then trace it out within your flash movie

package
{
	import flash.display.Sprite;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.events.Event;
	import flash.xml.XMLDocument;

	public class LoadXML extends Sprite
	{
		private var xml:XML;

		public function LoadXML()
		{
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, xmlDisplay);
			loader.load(new URLRequest("/path/to/xml/file/myfile.xml"));

		}

		private function xmlDisplay(e:Event):void
		{
			xml = new XML(e.target.data);
    		trace(xml);
		}
	}
}

Posted in Actionscript 3, Actionscript XML.


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Aidan Boyle says

    This was helpful. Thanks very much.



Some HTML is OK

or, reply to this post via trackback.