Chin
Chin

Reputation: 12712

Sandbox violation - in flash player - crossdomain issue?

I'm wondering if any has solved something similar to this.

I have a webpage on site-A which has an embedded swf served from site-B. The swf gives a security sandbox error when trying to a txt file via URLLoader from a folder on site-B.

I have a crossdomain policy on site-B (Currently set to ). I'm I missing something here? Where can I put the text file so that the swf can load it? I have access to both site A and B.

Any help much appreciated

Upvotes: 0

Views: 677

Answers (1)

George Profenza
George Profenza

Reputation: 51847

It depends on how you compile you swf. There is a Security Sanbox issue. There is a whole chapter in Essential Actionscript 3.0 on security, but I'll try to keep it short.

Using the Flash IDE, you have two 'security options' either your swf has permissions to load clips locally ( from the same domain ), either from network( other domains )

Let's say swfA is the swf on site-A and swfB is the swf on site-B

First thing, try to set a LoaderContext to the loader that you use for swfB

e.g.

//1st param(true) in LoaderContext constructor means always check for policy files 
var swfBLoaderContext:LoaderContext = new LoaderContext(true);
var swfBLoader:Loader = new Loader();
swfBLoader.contentLoaderInfo.addEventListener(Event.INIT, swfBLoaded);
swfBLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, swfBIOError);
swfBLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, swfBSecurityError);

swfBLoader.load(new URLRequest('http://siteb.com/b.swf',swfBLoaderContext);

function swfBLoaded(event:Event):void{
    trace(event.target.content);
}
function swfBIOError(event:IOErrorEvent):void{
    trace(event);
}
function swfBSecurityError(event:SecurityErrorEvent):void{
    trace(event);
}

Then change your local playback security in you Document Settings to access network files.

alt text http://www.adobe.com/devnet/flash/articles/local_network_playback/fig01.jpg

Thanks Adobe for the image.

For more details consult this article on devnet.

Goodluck.

Upvotes: 1

Related Questions