I have an issue with a child SWF loaded into a parent. The loading is pretty basic, everything should be ok. The problem is when the child has more than one frame, the SWF just loops indefinitely. When completed the child will have multiple frames and forward/back buttons, but I've distilled it down to two frames with a different image on each and no code save for stop(); I have another parent which I didn't create (and you don't want to see) that will accept an AS2 SWF but loops on AS3, which is where this whole project originated... Any insight is greatly appreciated....
This is the code for the parent:
var _swfLoader:Loader;
var _swfContent:MovieClip;
loadSWF("test4.swf");
function loadSWF(path:String):void {
var _req:URLRequest = new URLRequest();
_req.url = path;
_swfLoader = new Loader();
setupListeners(_swfLoader.contentLoaderInfo);
_swfLoader.load(_req);
}
function setupListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, addSWF);
dispatcher.addEventListener(ProgressEvent.PROGRESS, preloadSWF);
}
function preloadSWF(event:ProgressEvent):void {
var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
// swfPreloader.percentTF.text = _perc + "%";
}
function addSWF(event:Event):void {
event.target.removeEventListener(Event.COMPLETE, addSWF);
event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF);
_swfContent = event.target.content;
_swfContent.addEventListener("close", unloadSWF);
addChild(_swfContent);
}
function unloadSWF(event:Event):void {
_swfLoader.unloadAndStop();
removeChild(_swfContent);
_swfContent = null;
}