LoadXML();///this loads after Initialize addEventListener(Event.ADDED_TO_STAGE, Initialize);///this loads first
I want to keep ADDED _TO_STAGE because without it file doesn`t work properly.
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Author had a Free File of the Month
- Bought between 1 and 9 items
- Exclusive Author
- Europe
- Has been a member for 3-4 years
- Referred between 10 and 49 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
Listen for xml complete load and then call Initialize.
http://www.republicofcode.com/tutorials/flash/as3xml/Tryed that but it just give`s me a blank screen
Instead of adding an event listener after the xml load complete, try to first see if the object has already been added to stage. If it is, just simply call the Initialize function and if not, add an event listener. Like this:
if (stage) Initialize(null); else addEventListener(Event.ADDED_TO_STAGE, Initialize);
don’t forget removeEventListener.if not,xml will load by twice when swf load another swf.
thank you guys. fixed this
....
LoadXML();
private function LoadXML():void
{
var loader:URLLoader = new URLLoader(new URLRequest("xml/test.xml"));
loader.addEventListener(Event.COMPLETE, Initialize);
}
private function Initialize(event:Event):void
{
xml = new XML(event.target.data);
}
