Error #2148 or how to access local and network resources 4
I bet you all got already the Error #2148 when developing. In my case this happens often when I am developing an application where some resources are local and some are already from a backend server. For example I have a local config.xml just right next to my swf application and some other data from a backend server somewhere on another domain.
Now this is a problem as you can either publish your swf with local-security sandbox or network-security sandbox but in my case I need both as I have local resources and network resources. So I go through both ways;
local-security sandbox way

I can access my config.xml but when I try to load the data from another domain the following popup shows up:
In the Security Settings Manager that opens when you click Settings… you can add the remote domain and restart the browser then the swf should be able to access this domain. But I personally prefere the network-security sandbox way:
network-security sandbox way
Here you publish your swf with the network-security sandbox by adding the -use-network=true to the flex compiler or setting the Local playback security to Access network only in the Flash CS4 publish settings. This way your swf can access any domains from the internet. So in my case no problem to load the data from my backend server. But when load my local config.xml I get the following error:
Error #2148: SWF file file:///demo.swf cannot access local resource config.xml. Only local-with-filesystem and trusted local SWF files may access local resources.
The fastest solution to get rid of this error you go to the Security Settings Manager and add a new location for mac: / and for pc: c:/

The Security Settings Manager is a bit buggy. So restart your browser and check again if its really saved. Finally this entry allows the swf file to read local files. Here you allow full access to your machine which can be a security problem. It’s better to specify the root folder of your flash/flex projects. This way all your projects swf are trusted and can access all files in the subfolder of your flash/flex projects folder.
Thanks to a hint of nada there is a way to come around of the buggy Security Settings Manager. You can add a new cfg file in the FlashPlayerTrust directory (win: C:\windows\system32\Macromed\Flash\FlashPlayerTrust | mac: /Library/Application Support/Macromedia/FlashPlayerTrust ) and add your trusted folders in this cfg file. So my config file:
/Library/Application Support/Macromedia/FlashPlayerTrust/flexprojects.cfg
contains one single path to my flex projects:
/Users/mich/Flex Projects
And all my projects have access to local resources that are in this folder or in subfolders. One entry and you dont have to worry about any local access restrictions.
Summary
Both ways you are able to access both local and network resources. The advantage of the network-security sandbox way is that you have to add an entry only once and not every time you access a new domain. Specially if you set it up with your root flex/flash projects folder all your projects have automatically access.




