# Please help with Sandbox error 2121

**URL:** <https://forum.kirupa.com/t/please-help-with-sandbox-error-2121/330689>\
**Category:** Uncategorized\
**Created:** [February 28, 2013, 10:04pm UTC](https://forum.kirupa.com/t/please-help-with-sandbox-error-2121/330689 "2013-02-28T22:04:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bking20](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bking20](https://forum.kirupa.com/u/bking20)\
**Post date:** [February 28, 2013, 10:04pm UTC](https://forum.kirupa.com/t/please-help-with-sandbox-error-2121/330689/1 "2013-02-28T22:04:02Z")

</div>

I have a website on which I’m running a load.swf which loads a main.swf. I’m doing this so my users can see the download percentage. When I run the loader from Flashdevelop, it loads the .swf from my website (we’ll call it, [www.mysite.com/games/main.swf), but when I run the loader.swf from the site itself, I get a security sandbox 2121 error… "ecurityError: Error #2121: Security sandbox violation: LoaderInfo.content: [URL=“http://www.mysite.com/loader.swf”]www.mysite.com/loader.swf cannot access [URL=“http://www.mysite.com/games/main.swf”]www.mysite.com/games/main.swf](http://www.mysite.com/games/main.swf). This may be worked around by calling Security.allow"

Here’s my code for my loader.swf:  
package  
{  
import flash.display.Bitmap;  
import flash.display.Sprite;  
import flash.events.Event;  
import flash.net.URLRequest;  
import flash.display.Loader;  
import flash.events.ProgressEvent;  
import flash.text.TextField;  
import flash.text.TextFormat;  
import flash.system.Security;  
import flash.system.SecurityDomain;

/\*\*

- …
- @author xxxxxxx  
\*/  
public class Main extends Sprite  
{  
[Embed(source = “…/lib/title.png”)]  
public var sharkTitle:Class;

public function Main():void  
{  
if (stage) init();  
else addEventListener(Event.ADDED\_TO\_STAGE, init);  
}

private function init(e:Event = null):void  
{  
removeEventListener(Event.ADDED\_TO\_STAGE, init);  
// entry point

Security.allowDomain("_");  
Security.allowInsecureDomain("_");

var sharkTitle:Bitmap = new sharkTitle();  
sharkTitle.x = 250;  
sharkTitle.y = 70;  
sharkTitle.height = 150;  
sharkTitle.width = 310;  
var format:TextFormat = new TextFormat();  
format.size = 50;  
var percTxt:TextField = new TextField();  
percTxt.width = 500;  
percTxt.text = " ";  
percTxt.setTextFormat(format);  
percTxt.x = 300;  
percTxt.y = 250;

addChild(sharkTitle);  
addChild(percTxt);

function startLoad():void  
{  
var mLoader:Loader = new Loader();  
var mRequest:URLRequest = new URLRequest(“[www.mysite.com/games/main.swf](http://www.mysite.com/games/main.swf)”);  
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);  
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);  
mLoader.load(mRequest);  
}

function onCompleteHandler(loadEvent:Event):void  
{  
addChild(loadEvent.currentTarget.content);  
}

function onProgressHandler(mProgress: ProgressEvent):void  
{  
var percent:Number = mProgress.bytesLoaded / mProgress.bytesTotal;  
percent = percent \* 100;  
Math.ceil(percent);  
format.size = 50;  
percTxt.setTextFormat(format);  
percTxt.text = String(Math.ceil(percent)) + “% loaded”;  
percTxt.setTextFormat(format);  
if (percent \> 99) { percTxt.visible = false;}

}

startLoad();

}

}

Thanks to any advice you can give…
