Reading an xml file , take the path of another xm file from it and read it

Actually i’m facing one situation while reading an xml file externally whose path is provided in another xml file…i’m able to read it properly …but excution goes to next instruction b’fore it completely loads.
pls assist me in this regard…

here is my code.

[SIZE=2][LEFT]<?xml version=“1.0” encoding=“utf-8”?>[/LEFT]
[/SIZE][SIZE=2][COLOR=#0000ff][LEFT]<mx:Application[/COLOR][/SIZE][SIZE=2] xmlns:mx="[/SIZE][SIZE=2][COLOR=#990000]http://www.adobe.com/2006/mxml[/COLOR][/SIZE][SIZE=2]" layout="[/SIZE][SIZE=2][COLOR=#990000]absolute[/COLOR][/SIZE][SIZE=2]" creationComplete=“serv.send()” viewSourceURL="[/SIZE][SIZE=2][COLOR=#990000]srcview/index.html[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]>[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#006633]<mx:Script>[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT]<![CDATA[

[/SIZE]*[SIZE=2][COLOR=#009900]//import mx.preloaders.Preloader[/LEFT]
*[/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][SIZE=2] mx.rpc.events.ResultEvent;
[/SIZE][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][SIZE=2] mx.rpc.events.FaultEvent;
[/SIZE][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][SIZE=2] flash.display.Sprite;
[/SIZE][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][SIZE=2] mx.controls.Alert;
[/SIZE][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][SIZE=2] flash.events.Event;
[/SIZE][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][SIZE=2] flash.net.URLLoader;
[/SIZE][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][SIZE=2] flash.net.URLRequest;

[/SIZE][SIZE=2][COLOR=#0033ff]public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][SIZE=2] urlLoader:URLLoader;
[/SIZE]*[SIZE=2][COLOR=#009900]//public var preLoader:Pre;[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT]
[/SIZE][SIZE=2][COLOR=#0033ff]public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][SIZE=2] externalXML:XML;
[/SIZE]
[SIZE=2][COLOR=#009900]//public var externalXML123:XML; [/LEFT]
*[/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#0033ff]public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][SIZE=2] xmltree:XmlTree;

[/SIZE][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][SIZE=2] init(event:ResultEvent):[/SIZE][SIZE=2][COLOR=#0033ff]void[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT]{
[/SIZE]
[SIZE=2][COLOR=#6699cc]var
[/COLOR][/SIZE][SIZE=2] xml:XML = [/SIZE][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][SIZE=2] XML(event.result);
xmltree = [/SIZE][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][SIZE=2] XmlTree();

[/SIZE]*[SIZE=2][COLOR=#009900]//trace(xml.toString());[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#009900]//trace(xml.Model.path.@File);[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT]
[/SIZE][SIZE=2][COLOR=#cc6666]trace[/COLOR][/SIZE]SIZE=2;
[/SIZE][SIZE=2][COLOR=#cc6666]trace[/COLOR][/SIZE]SIZE=2;
[/SIZE]
[SIZE=2][COLOR=#009900]//loadXML1(“ProjectInfo1.xml”);[/LEFT]
*[/COLOR][/SIZE][SIZE=2][LEFT]

loadXML1(xml.Model.path.@File);

[/SIZE]*[SIZE=2][COLOR=#009900]//xml.Model.path=externalXML123;[/LEFT]
*[/COLOR][/SIZE][SIZE=2][LEFT]
xmltree.loadXml(xml);
xmltree.width = 800;
xmltree.height = 800;
[/SIZE][SIZE=2][COLOR=#0033ff]this[/COLOR][/SIZE][SIZE=2].addChild(xmltree);
}

[/SIZE][SIZE=2][COLOR=#0033ff]public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][SIZE=2] loadXML1(url:String):[/SIZE][SIZE=2][COLOR=#0033ff]void[/COLOR][/SIZE][SIZE=2] {

[/SIZE][SIZE=2][COLOR=#0033ff]if[/COLOR][/SIZE][SIZE=2] (urlLoader != [/SIZE][SIZE=2][COLOR=#0033ff]null[/COLOR][/SIZE][SIZE=2]) {
urlLoader.close(); }

urlLoader = [/SIZE][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][SIZE=2] URLLoader();
[/SIZE]*[SIZE=2][COLOR=#009900]//preLoader=new pre();[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT]
urlLoader.addEventListener(Event.COMPLETE, onXMLLoad);
urlLoader.load([/SIZE][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][SIZE=2] URLRequest(url));
urlLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
[/SIZE]
[SIZE=2][COLOR=#009900]//preLoader.pre(); [/LEFT]
*[/COLOR][/SIZE][SIZE=2][LEFT]}

[/SIZE][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][SIZE=2] onXMLLoad(event:Event):[/SIZE]**[SIZE=2][COLOR=#0033ff]void[/LEFT]
**[/COLOR][/SIZE][SIZE=2][LEFT]{

externalXML = XML(event.target.data);
[/SIZE]*[SIZE=2][COLOR=#009900]//externalXML123=externalXML[/LEFT]
*[/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#cc6666]trace[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#990000]“loader is a URLLoader!”[/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#cc6666]trace[/COLOR][/SIZE]SIZE=2;

[/SIZE]*[SIZE=2][COLOR=#009900]/*if (loader != null)
{
externalXML = new XML(loader.data);

trace(“loader is a URLLoader!”);
//trace(externalXML.tostring());
}
else
{
trace(“loader is not a URLLoader!”);
} /[/COLOR][/SIZE][SIZE=2]

}

[/SIZE][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][SIZE=2] progressHandler(event:ProgressEvent):[/SIZE][SIZE=2][COLOR=#0033ff]void[/COLOR][/SIZE][SIZE=2] {
[/SIZE][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][SIZE=2] perc:Number = event.bytesLoaded / event.bytesTotal; [/SIZE]*[SIZE=2][COLOR=#009900]//while(perc != 100);[/LEFT]
*[/COLOR][/SIZE][SIZE=2][LEFT]

[/SIZE][SIZE=2][COLOR=#cc6666]trace[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#990000]“progressHandler loaded:”[/COLOR][/SIZE][SIZE=2] + event.bytesLoaded + [/SIZE][SIZE=2][COLOR=#990000]" total: "[/COLOR][/SIZE][SIZE=2] + event.bytesTotal);
}

[/SIZE][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][SIZE=2] serv_fault(evt:FaultEvent):[/SIZE][SIZE=2][COLOR=#0033ff]void[/COLOR][/SIZE][SIZE=2] {
Alert.show(evt.fault.faultString);
}

]]>
[/SIZE][SIZE=2][COLOR=#006633]</mx:Script>[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#0000ff]<mx:String[/COLOR][/SIZE][SIZE=2] id="[/SIZE][SIZE=2][COLOR=#990000]XML_URL[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][SIZE=2]assets/ProjectInfo1.xml[/SIZE][SIZE=2][COLOR=#0000ff]</mx:String>[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#0000ff]<mx:HTTPService[/COLOR][/SIZE][SIZE=2] id="[/SIZE][SIZE=2][COLOR=#990000]serv[/COLOR][/SIZE][SIZE=2]" url="[/SIZE][SIZE=2][COLOR=#990000]{[/COLOR][/SIZE][SIZE=2]XML_URL[/SIZE][SIZE=2][COLOR=#990000]}[/COLOR][/SIZE][SIZE=2]" resultFormat="[/SIZE][SIZE=2][COLOR=#990000]text[/COLOR][/SIZE][SIZE=2]" result=“init(event);” fault=“serv_fault(event);”[/SIZE][SIZE=2][COLOR=#0000ff]/>[/LEFT]
[/COLOR][/SIZE][SIZE=2][LEFT][/LEFT]
[/SIZE][SIZE=2][COLOR=#0000ff][LEFT]</mx:Application>:([/LEFT]
[/COLOR][/SIZE]