Skip to main content
sivacse24rep
Inspiring
January 9, 2013
Answered

Security sandbox violation on Air file

  • January 9, 2013
  • 1 reply
  • 2546 views

Hi,

I have a air package called "test_sandBox" -->will be installed under " c:\program files\"

this "test_sandBox" will load another swf from c:\test\samp.swf. on test_sandBox i wont write any other function in feature. If i want to add anything i will add the feature on samp.swf and i will udpate that in c:\test\. So at any cost am not in need to reinstall the air package again. i am not able to update the samp.swf on "c:\program files\"  due to some security issue on windows 7. So i decide to update the samp.swf on c:\test\

the "test_sandBox.fla" have the following code

import flash.display.Loader;

init();

var _defaultLoader:Loader;

function init()

{    _defaultLoader=new Loader();

    _defaultLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onGameLoadComplete, false, 0, true);       

    var urlRequest:URLRequest=new URLRequest("C:/digient_casino/samp.swf");

    _defaultLoader.load(urlRequest);

}

function onGameLoadComplete(e:Event)

{

    mc.addChild(_defaultLoader.content);

    var mc1=MovieClip(_defaultLoader.content);

    mc1.updatePath("",stage);

}

the samp.fla have following code:

import flash.events.Event;

var stageObject:Object;

function updatePath(path:String,sObj:Object)

{

    stageObject=sObj;   

}

mc.buttonMode=true;

mc.addEventListener(MouseEvent.CLICK,fullScreen);

function  fullScreen(e:Event)

{

     stageObject.displayState = StageDisplayState.FULL_SCREEN;

   // stage.displayState = StageDisplayState.FULL_SCREEN;

}

Issue:

When i run the "test_sandBox" --> it load the samp.swf and when i press the full screen button on the samp.swf it shows the following error

*** Security Sandbox Violation ***

SecurityDomain 'file:///C:/test/samp.swf' tried to access incompatible context 'app:/test_sandBox.swf'

SecurityError: Error #2070: Security sandbox violation: caller file:///C:/test/samp.swf cannot access Stage owned by app:/test_sandBox.swf.

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

    at flash.display::Stage/set displayState()

    at samp_fla::MainTimeline/fullScreen()

How to solve this issue?

Thanks,

Siva

This topic has been closed for replies.
Correct answer moccamaximum

This article describes the problem you have run into:

In short: Change the line

_defaultLoader.load(urlRequest);

to

_defaultLoader.loadBytes(urlRequest);

Make sure to read the article, why this workaround should only be used during development, since it poses a security risk.

1 reply

moccamaximumCorrect answer
Inspiring
January 9, 2013

This article describes the problem you have run into:

In short: Change the line

_defaultLoader.load(urlRequest);

to

_defaultLoader.loadBytes(urlRequest);

Make sure to read the article, why this workaround should only be used during development, since it poses a security risk.

sivacse24rep
Inspiring
January 9, 2013

Yes i read the article. But when i use _defaultLoader.loadBytes(urlRequest); it says type conversion error. loadBytes should use the ByteArray. how to do that?

Thanks,

Siva

Inspiring
January 9, 2013

add this in your test_sandbox.fla/init

var loaderContext: LoaderContext = new LoaderContext();
loaderContext
.allowLoadBytesCodeExecution = true;
_defaultLoader.loaderContext = loaderContext;

make sure to take care of necessary imports

a complete code example can be found here