Link to home
Start Free TrialLog in
Avatar of frankybones
frankybones

asked on

how to parse xml with string path

okay,

so I have been making a very slow--VERY SLOW--conversion to AS3.  Mostly because my job duties changed for a bit and i was doing more design work than programming.  But here I am again back at the programming side of things. YEA!

My Point:

I am trying to write my xml loader as reusable object in itself.  So that when another object that relies on xml data is loaded it just simply calls my xml object and then goes from there.  I have attached my code below, but this does not work--completely.  it shows the path but still tells me code no joy! in the out put window.  any ideas what i am missing / doing wrong?

Thanks for your help in advance.

-Frankie
package {
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.events.*;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.xml.*;

	public class XMLEngine extends MovieClip {
		public var xmlPath:String;
		private var theXML:XML;
		private var loader:URLLoader;
		public function XMLEngine() {
			//constructor
		}
		private function loadXML(request):void {
			var loader:URLLoader=new URLLoader();
			loader.addEventListener(Event.COMPLETE,completeHandler);
			try {
				loader.load(request);
			} catch (error:Error) {
				trace('we have code no joy!');
			}
		}
		private function completeHandler(e:Event) {
			var loader:URLLoader=URLLoader(e.target);
			var result:XML=new XML(loader.data);
			var myXML:XMLDocument=new XMLDocument();
			myXML.ignoreWhite=true;
			myXML.parseXML(result.toXMLString());
		}
		public function getPath(urlPath:String) {
			if (urlPath) {
				xmlPath=urlPath;
				trace("theXML.load("+xmlPath+")");
				loadXML(xmlPath);
			}
		}
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of frankybones
frankybones

ASKER

you rock as usual blue, thank you for taking a look-see!
To answer your question of how I plan to implement the code.  The idea I am using is to have the XMLEngine class as it's own object that other objects extend or import.  Have not figured out how to do that just yet, as I am still getting the hang of the new syntax and OOP.