Load XML with LoaderMax
I did have my own set of classes that I use for loading files(images/xml etc) but since I use Greensock for tweening I figured I should use it for loading my assets as well.
//import the classes, u dont need easing for this but you should be using it
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;
//above your class constructor function
private var _loaderMax:LoaderMax;
private var _xml:XML;
//in your code where you want to use it
private function loadXML():void {
_loaderMax = new LoaderMax({name:"mainQueue", onComplete:completeHandler, onError:errorHandler});
_loaderMax.append( new XMLLoader("yourFile.xml", {name:"xmlDoc"}) );
_loaderMax.load();
}
private function completeHandler(event:LoaderEvent):void {
_xml = LoaderMax.getContent("xmlDoc");
}
private function errorHandler(event:LoaderEvent):void {
trace("error occured with " + event.target + ": " + event.text);
}
Thank you for this. For GreenSock being such a great tool, it was tough finding simple examples such as this one. Thanks again.
No problem! Glad you found it useful.
Hey. Have you found any load issues with GS LoaderMax on FF for Windows 7. It seems to hang and never fires the onComplete function? Any insight would be awesome. I am not experiencing this in any other browser or platform.
figured this out. my xml (which was dynamically being generated) had this line:
because some of our nodes didn’t have images. it needed to be:
not a fun QA process for me, but i figure I’d let you know that I figured it before you looked into the issue. Thanks anyway.
Thanks for the heads up. The code snippet didn’t come through though. Mind re-posting?