Skip to main content
Known Participant
November 28, 2013
Answered

Load SWF inside naviteWindow [AIR]

  • November 28, 2013
  • 1 reply
  • 1982 views

Hello,

I have an AIR application where I have to load a SWF from a server.

At some point the user will click on a button and that button will create a new nativeWindow.

Inside that nativeWindow we have a stage reference.

I just want to load a SWF, addChild it to the stage and be happy!  😛

But I'm getting this error:

SecurityError: Error #2070: Security sandbox violation: caller http://somewhere.com/swfapp.swf cannot access Stage owned by app:/Teste.swf.

at flash.display::Stage/get stageWidth()

at com.swfapp::MainClass/initApp()

at flash.display::DisplayObjectContainer/addChild()

at flash.display::Stage/addChild()

at NativeWindowSWFLoader/loadSWFURLComplete()

I'm using a normal Loader:

private function loadSWFFromURL():void

{

          var context:LoaderContext = new LoaderContext();

          context.applicationDomain = ApplicationDomain.currentDomain;

          context.securityDomain = SecurityDomain.currentDomain;

          context.allowLoadBytesCodeExecution = true;

          context.allowCodeImport = true;

          loaderSWFURL = new Loader();

          loaderSWFURL.contentLoaderInfo.addEventListener(Event.COMPLETE, loadSWFURLComplete);

          loaderSWFURL.load(new URLRequest(urlSWF));

}

private function loadSWFURLComplete(e:Event):void

{

              //var loaderInfo:LoaderInfo = LoaderInfo(e.target);

              //var byteArray:ByteArray = loaderInfo.bytes;

               this.stage.addChild(loaderSWFURL);

}

Can someone hep me on this?

Thank you.

This topic has been closed for replies.
Correct answer kglad

you need a cross-domain permissions file on you somewhere.com to use the loader class.

or you could use the HTMLLoader class without one:

var htmlLoader:HTMLLoader=new HTMLLoader();

htmlLoader.width=stage.stageWidth;

htmlLoader.height=stage.stageHeight;

htmlLoader.load(new URLRequest("http://somewhere.com/swfApp.swf"));

addChild(htmlLoader);

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 28, 2013

you need a cross-domain permissions file on you somewhere.com to use the loader class.

or you could use the HTMLLoader class without one:

var htmlLoader:HTMLLoader=new HTMLLoader();

htmlLoader.width=stage.stageWidth;

htmlLoader.height=stage.stageHeight;

htmlLoader.load(new URLRequest("http://somewhere.com/swfApp.swf"));

addChild(htmlLoader);

croxoverAuthor
Known Participant
November 29, 2013

Hey kglad,

Thank you, for your reply.

The HTMLLoader fixed my problem aparently. Now I can load a SWF on a new nativeWindow.

I tested my my PC without problems, but when I tested on a MAC the SWF wasn't loaded.
Only a white screen happens on the MAC.

Is theres a bogus on MAC?
Any other configuration to be done?


Thank you.

kglad
Community Expert
Community Expert
November 29, 2013

no, it's supposed to work across desktops.  you can use the static isSupported property of the htmlloader class to make sure it's supported on your mac desktop/laptop.