I have a Flex application that just load an external SWF, but the application load and unload infinitely my swf.
The embeded as3 code is:
<![CDATA[
import mx.events.FlexEvent;
private var m_Application:Application;
private function initGenderMenuApp(evt:FlexEvent):void{
m_Application = evt.target as Application;
m_Application.removeEventListener( FlexEvent.APPLICATION_COMPLETE, initMenuApp );
var loader:Loader = new Loader();
trace("initApp");
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onFailedLoad);
loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadedApp );
loader.load( new URLRequest( "application.swf" ));
}
private function onFailedLoad( evt:Event ):void{
trace("ERROR", evt.target);
}
private function onLoadedApp( evt:Event ):void{
trace("Loading Application..");
var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
loaderInfo.removeEventListener( Event.COMPLETE, onLoadedApp);
trace(loaderInfo.loader.content);
m_Application.addElement( new SpriteUIComponent( evt.target.loader.content as MovieClip));
}
]]>
SpriteUIComponent is used to add the SWF as Sprite on the stage.
Regards