views:

3282

answers:

4

What is a security sandbox violation, and how do I override it? I'm making a project in FlashDevelop, and today, it will not load external files, even though it had been previously. It gives the following output:

********* Security Sandbox Violation ***** Connection to file:///C|/Documents%20and%20Settings/Kevin.PC885314341208/Desktop/Import%20.txt/StockData/1.txt halted - not permitted from file:///C|/Documents%20and%20Settings/Kevin.PC885314341208/Desktop/Import%20.txt/import.swf

I hope this isn't a serious problem.

Thanks for any help.

+1  A: 

You're loading a local file, something that's not permitted. However, as you're developing this you can of course allow this.

Add your project folder to the trusted locations: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

Edit: I might add that if you run it with networking disabled it will work (this is for development purposes). This happens for example when you run it from the Flash IDE, which would explain why it may have worked before?

Antti
Running a swf from the Flash IDE actually runs it in privileged mode: it has access to local and network resources. It's when you run it in a standalone flash player that it can access only one of local or network resources.
aaaidan
A: 

OK. I got it to work by publishing it using FlashDevelop's built in flashplayer (I don't know how to describe it better). I wasn't able to use the security settings that Antti suggested though.

kevin
In FlashDevelop's project properties (under Compiler Options tab) there is a setting "Use Network Services". If you set this to true you can access ONLY the internet, and false allows ONLY local files. Can't have both.
aaaidan
The reason it works in the "built in" player is because it probably runs in "privileged mode", which allows access to both local and network resources. This mode is only available during development, so you can't rely on it for deployment.
aaaidan
+1  A: 

You cannot load desktop files when you try to run a SWF through a web browser. Flash does not give you access to the local hard drive, as that would be a major security issue. You will have to place those files on a server somewhere and pass Flash a direct URL.

Jeff Winkworth
+2  A: 

The error message you posted shows that you're trying to load a local file from a local swf. This error can be fixed for your scenario.

In FlashDevelop, set "Use Network Services" to false (Project Properties -> Compiler Options tab). This will prevent your swf from accessing the internet but will let you load local files. Setting it to true will allow internet access but not access to local files.

In Flash, the setting is under "Publish Settings", Flash tab. It's called "Local playback security" and the settings are "Access local files only" or "Access network only". It's the same setting as in FlashDevelop, just a different name.

You can also switch the "Use Network" flag of a swf file after publish/compile by using the Adobe's free+open Local Content Updater.

aaaidan
This solution works
kevin