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