I've added a SWF file to the included files list in Publish Settings that I would like to load.
Any ideas on how to get it to work?
Here is my code:
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.filesystem.File;
function startLoad()
{
var file:File = File.applicationDirectory.resolvePath("SomeFile.swf");
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest(file.url);
var context:LoaderContext = new LoaderContext();
context.checkPolicyFile = true;
context.securityDomain = SecurityDomain.currentDomain;
context.applicationDomain = ApplicationDomain.currentDomain;
mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
mLoader.contentLoaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleGlobalErrors);
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
try {
mLoader.load(mRequest, context);
} catch (error:Error) { mLoader.load(mRequest);
}
}
function handleGlobalErrors( evt : UncaughtErrorEvent ):void
{
evt.preventDefault();
}
function onCompleteHandler(loadEvent:Event)
{
addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent)
{ var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal; trace(percent);
}
function ioError(event:ErrorEvent):void {
}
startLoad();