ActionScript Error #2148:
SecurityError: Error #2148: SWF file file:///C:/Documents and Settings/UserProfile/Desktop/flexstore/bin-release/flexstore.swf cannot access local resource myFile.swf. Only local-with-filesystem and trusted local SWF files may access local resources.
Description:
ActionScript Error #2148 can be caused by a number of reasons. If you are using Flex please keep in mind that the bin directory is a special directory that the Flash player allows SWFs ( and other files ) to load from as long as the file is stored in this directory. It will also allow a loaded swf to access network resources (a remote HTTPService call for example). If these files are placed anywhere besides the bin directory, the Flash Player prevents the file from accessing any external resources. You can allow for external access by changing the settings within the FlashPlayer or within Flex. These solutions are listed below
Fix 1 :
If you're loading in XML or other files from a remote sever that isn't hosting the SWF too, make sure you create a crossdomain.xml policy, and put it on the root of your webserver. If you haven't heard about a cross domain policy or need help creating a crossdomain.xml file click the link and I will show you how to create a crossdomain.xml file. View my tutorial on How to Create a crossdomain.xml file and visit the links on the bottom of the page to learn more.
XML Code:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policySYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.curtismorley.com" />
<allow-access-from domain="curtismorley.com" />
</cross-domain-policy>
Fix 2:
Within ActionScript you are now able to specify the cross domain access from within the code. I won't get into the guts of this one but if you want to learn more view the Flash / Flex documentation or Adobe LiveDocs - Security Chapter or get Joey Lott's book ActionScript 3 Cookbook By adding this code you will get rid of ActionScript Error #2148 If you are using https:// you will need to use allowInsecureDomain() as shown below. If you are using a local file make sure to target it correctly(i.e. c:\myFolder).
ActionScript Code:
flash.system.Security.allowDomain("http://www.curtismorley.com");flash.system.Security.allowInsecureDomain("http://www.curtismorley.com");
Fix 3:
One hack to get rid of ActionScript Error 2148 is to add these arguments to the compiler (via Properties - Flex Compiler) : -use-network=false . Beware though this will effectively change your cross-domain security.
Good Code:
-use-network=false
Fix 4:
Make sure your Global Security Settings in Flash Player allows local access to the directory your SWF/XML is running from. At the Global Security Settings in Flash Player click on Edit locations >> Add location and then either type in the new location your SWF is at (i.e. c:\myFolder) or browse for the file or folder. Shut down Flash/ Flex and all instances of the Flash Player(including browsers), and then try again. This will eliminate this ActionScript Error #2148. This solution only works for you on your computer. If you cahnge computers or change locations on the web please refer back to Fix 1.
And now you know 2 ways to fix and 2 ways to circumvent ActionScript Error #2418: Security Error
Happy Flashing
分享到:
相关推荐
详细介绍了FLEX安全沙箱,便于大家开发FLEX时参考使用。
全面认识Flex安全沙箱 flex4发布后在IE中运行出现的安全沙箱问题。
在Adobe Flash Player升级到9.0.124后,由于安全策略更改,原来Socket或XmlSocket的应用里的http方式加载安全策略的手段不能继续使用。...connectbysocket 是flex客户端 connectbysocket请放在tomcat下试验效果
flex 沙箱安全问题 remoteobject Error #2048
电信设备-克服flex安全沙箱限制的视频像素信息采集存储的方法.zip
NULL 博文链接:https://wuxiubing.iteye.com/blog/1354175
沙箱安全系统解决方案设计-研华.pdf沙箱安全系统解决方案设计-研华.pdf沙箱安全系统解决方案设计-研华.pdf沙箱安全系统解决方案设计-研华.pdf沙箱安全系统解决方案设计-研华.pdf沙箱安全系统解决方案设计-研华.pdf...
网上的方法很多,我看了好多,但是就是不管用,我的情况是,在程序没发布时,直接运行没错误,但是当发布时,访问就错了,提示SecurityError: Error #2048: 安全沙箱冲突:http://localhost:8086/index.swf 不能从 ...
解压缩后直接运行FlexSecurity.bat。解决flex安全沙箱问题。无需到Adobe的官网上去设置全局安全域。
FLASH PLAYER中的一个主要安全性组件基于沙箱,是FLASH PLAYER用于包含资源的逻辑安全性分组。 FLASH PLAYER使用安全沙箱来定义各个FLASH应用程序可以访问的操作的范围,即他们可以访问哪些资源。 各个沙箱的所有...
当a.com中的flash要访问b.com中的资源(如图片等)时,flex会提示安全沙箱错误!
flash安全沙箱汇总。从网上摘录的东东。
NULL 博文链接:https://honley.iteye.com/blog/1159473
目录 1.安全沙箱容器 2.EdgeKubernetes 3.安全沙箱容器@edge方案 4.新探索 随着云计算边界不断向边缘...了解安全容器在落地过程中在网络、监控、日志、存储以及 K8s API 兼容等方面遇到的种种困难和挑战以及解决方案。
java ,c#,delphi 解决flash安全沙箱问题 聊天室
要要安全沙箱是一款免费国产沙箱软件,为用户提供方便,专业,纯粹的沙箱产品。用户可以在要要安全沙箱环境中运行浏览器,软件等程序,沙箱中运行和程序不会对系统和电脑产生任何的实际的更改和影响,程序运行所产生...
本程序为绿色mini服务程序 程序会自动打开Flash默认的843端 自动将crossdomain.xml返回给flash客户端 您可以修改crossdomain.xml中的内容,大小不要超过10K 有问题可email我
这是个通用类,里面包含了处理843端口的安全沙箱问题以及socket基本的向服务器send资源问题。 请求方式是,先发整形,然后发id长度,再发id(String) 得到的资源是先得到字符长度,再得到字符串。这个是和后退约定的...
NULL 博文链接:https://renzaihangzhou.iteye.com/blog/2007855
Sandboxie(英译“沙盘”)允许你在...可用来保护浏览网页时真实系统的安全,也可以用来清除上网、运行程序的痕迹,还可以用来测试软件,测试病毒等用途。即使在沙盘进程中下载的文件,也可以随着沙盘的清空而删除。