Skip to content

Instantly share code, notes, and snippets.

@matthua
Created April 12, 2013 10:27
Show Gist options
  • Save matthua/5371100 to your computer and use it in GitHub Desktop.
Save matthua/5371100 to your computer and use it in GitHub Desktop.
Externally hosting secondary swf files (iOS)
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
public class SampleMainSwf extends Sprite
{
private var externalLoader:Loader;
private var url:String= "http://www.xyz.com/Level1.swf";
private var urlRequest:URLRequest = new URLRequest(url);
private var ldrContext:LoaderContext;
public function SampleMainSwf()
{
externalLoader = new Loader();
externalLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
externalLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,errorHandler);
ldrContext=new LoaderContext(false,ApplicationDomain.currentDomain,null);
try
{
externalLoader.load(urlRequest, ldrContext);
}
catch(e:Error)
{
trace("Error ID : "+e.errorID+"\nError Message : "+e.message);
}
}
private function completeHandler(e:Event):void
{
addChild(externalLoader);
}
private function errorHandler(e:IOErrorEvent):void
{
trace("In IO ErrorEvent Handler");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment