[flexcoders] Loading XML in preloader/ before application onComplete
Hi, I am creating a flex application that has its UI elements and some basic data that are dependent upon a config.xml. Loading the config.xml on application preinitialize/initialize/onComplete would not be appropriate as my application preloading would be complete and I still dont see any UI elements on the screen. Creating second preloader on initialize would not look that great. I am pretty sure we can load the XML in the preloader and delay/deffer the application instantiation. Just not sure how to go about it and what API's should I look for or where exactly should I use them. Appreciate a lead on how to go about it. Thank you, Varun Shetty
Re: [flexcoders] Loading XML in preloader/ before application onComplete
Extend the DownloadProgressBar Class (name it e.g myPreloader) and override the preloader: override public function set preloader(value:Sprite):void { value.addEventListener(FlexEvent.INIT_COMPLETE, FlexInitComplete); // I added my download function to the INIT_COMPLETE event } Write sometihing like this as the event handler: private function FlexInitComplete(event:Event):void { Security.loadPolicyFile([you'll need a policy file I guess]); var getXMLReq:URLRequest = new URLRequest(http:// [whatever].xml); var xmlLoader:URLLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); xmlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); try { xmlLoader.load(getXMLReq); } catch (error:Error) { trace(Unable to load requested document.); Alert.show(Security error + error.errorID.toString()); } } Then sth. like this ... private function xmlLoaded(event:Event):void { var loader:URLLoader = URLLoader(event.target); var theXML:XML = new XML(loader.data); } Check the DownloadProgressBar doc for some more events to complete the process In the Application tag set your preloader Application . . preloader=myPreloader . . / Hope that helps somehow ... for me it works. On 03.04.2008, at 17:28, Varun Shetty wrote: Hi, I am creating a flex application that has its UI elements and some basic data that are dependent upon a config.xml. Loading the config.xml on application preinitialize/initialize/ onComplete would not be appropriate as my application preloading would be complete and I still dont see any UI elements on the screen. Creating second preloader on initialize would not look that great. I am pretty sure we can load the XML in the preloader and delay/ deffer the application instantiation. Just not sure how to go about it and what API's should I look for or where exactly should I use them. Appreciate a lead on how to go about it. Thank you, Varun Shetty
Re: [flexcoders] Loading XML in preloader/ before application onComplete
Wow, that is pretty descriptive... thank you very much Rico...! umm.. so Extending the downloadprogressbar class is the way... I will try it out in sometime. Thank you very much for your help.. regards, Varun Shetty On Thu, Apr 3, 2008 at 1:26 PM, Rico Leuthold [EMAIL PROTECTED] wrote: Extend the DownloadProgressBar Class (name it e.g myPreloader) and override the preloader: override public function set preloader(value:Sprite):void { value.addEventListener(FlexEvent.INIT_COMPLETE, FlexInitComplete); // I added my download function to the INIT_COMPLETE event } Write sometihing like this as the event handler: private function FlexInitComplete(event:Event):void { Security.loadPolicyFile([you'll need a policy file I guess]); var getXMLReq:URLRequest = new URLRequest(http:// [whatever].xml); var xmlLoader:URLLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); xmlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); try { xmlLoader.load(getXMLReq); } catch (error:Error) { trace(Unable to load requested document.); Alert.show(Security error + error.errorID.toString()); } } Then sth. like this ... private function xmlLoaded(event:Event):void { var loader:URLLoader = URLLoader(event.target); var theXML:XML = new XML(loader.data); } Check the DownloadProgressBar doc for some more events to complete the process In the Application tag set your preloader Application . . preloader=myPreloader . . / Hope that helps somehow ... for me it works. On 03.04.2008, at 17:28, Varun Shetty wrote: Hi, I am creating a flex application that has its UI elements and some basic data that are dependent upon a config.xml. Loading the config.xml on application preinitialize/initialize/onComplete would not be appropriate as my application preloading would be complete and I still dont see any UI elements on the screen. Creating second preloader on initialize would not look that great. I am pretty sure we can load the XML in the preloader and delay/deffer the application instantiation. Just not sure how to go about it and what API's should I look for or where exactly should I use them. Appreciate a lead on how to go about it. Thank you, Varun Shetty