views:

349

answers:

1

I'm loading a rather large swf as style with the following command:

StyleManager.loadStyleDeclarations("assets/modules/"style.swf",true,false,ApplicationDomain.currentDomain);

The style is loaded fine but now I would like to add a progress bar to it, but I do not know how to do so. I am rather new to Flex and found only examples referring to HTML service calls.

Thank You for Your Help. It would be great to receive a small code example.

A: 
var dispatcher:IEventDispatcher = StyleManager.loadStyleDeclarations(
        "assets/modules/style.swf",true,false,ApplicationDomain.currentDomain);

dispatcher.addEventListener(StyleEvent.PROGRESS, onProgress);
dispatcher.addEventListener(StyleEvent.COMPLETE, onComplete);
dispatcher.addEventListener(StyleEvent.ERROR, onError);

private function onProgress(e:StyleEvent):void
{
    //update progress bar here
    trace(Math.floor(100 * e.bytesLoaded/e.bytesTotal) + "% loaded");
}
private function onComplete(e:StyleEvent):void
{
    trace("Style loaded");
}
private function onError(e:StyleEvent):void
{
    trace("Error loading style");
}
Amarghosh