0

I am trying to load external swf file into my AIR application and of course AIR gives me security violation exception.

Now I am trying to find workaround in more hackable way, first load swf with Loader, set

var context:LoaderContext = new LoaderContext();            
context.allowCodeImport = true;

and then convert my Loader into SWFLoader.

Here is the complete example:

var _loader:Loader = new Loader();
var context:LoaderContext = new LoaderContext();            
context.allowCodeImport = true;
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
_loaderload(new URLRequest("Y:/dev/Pdf2SwfProj/fscommand/pdfurl-guide.swf"), context);


public function loadComplete(event:Event):void
{
    // This is the part I am intrested in, how to convert data loaded into SWFLoader ?
    var swfLaoder : SWFLoader = SWFLoader(event.target);
}

Thank you.

inside
  • 3,047
  • 10
  • 49
  • 75

1 Answers1

0

Ah... Got it working! But if anyone is interested in answer - here it is:

public function loadComplete(event:Event):void
{
   var swfLoader:SWFLoader = SWFLoader();
   var context:LoaderContext = new LoaderContext();         
   context.allowCodeImport = true;
   swfLoader.loaderContext = context;
   swfLoader.source = event.target.bytes;
}
inside
  • 3,047
  • 10
  • 49
  • 75