0
点赞
收藏
分享

微信扫一扫

FLEX实践—加载XML文件错误


     这两天在研究一个FLEX小相册,准备做一个超级简单的纯FLEX相册,没想到在读取XML文件的时候遇到了这样一个问题:

     1)用FLEX BUILDER创建了一个FLEX工程

     2)写了一个MXML文件,一个XML文件

     3)在程序中用HTTPService和URLRequest两种方法分别读取XML文件内容

     4)直接在Flex Buidler中编译运行,一切正常

     5)直接运行在bin-debug目录下生成的swf文件,一切正常

     6)将该SWF文件剪切到另外一个目录下运行,报出了以下错误:

SecurityError: Error #2148: SWF 文件 [url=file:///F:/CollegeFile/photo.xml] file:///F: /CollegeLife/CollegeLife.swf 不能访问本地资源 1.xml。只有仅限于文件系统的 SWF 文件和可信的本地 SWF 文件可以访问本地资源。

 

刚开始还以为是程序有问题,可是后来想想没理由在Flex Buidler中能运行,在其他目录下就不能运行,于是上网搜了一下,找到这样的说法:

     

      而在编译文件时有这么一个参数设置--->use-network=true|false

      关于该参数设置的解释是这样的:

Specifies that the current application uses network services.
The default value is true.
When the use-network property is set to false, the application can access the local filesystem (for example, use the XML.load() method with file: URLs) but not network services. In most circumstances, the value of this property should be true.
For more information about the use-network property, see Applying Flex Security.

 

      7)接下来,问题解决方案出来了:将运行时参数 -use-network=false就OK了,具体做法是

      flex项目上点右键-->properties-->ActionscriptCompiler-->Additional compiler arguments
加上  “ -use-network=false ”

举报

相关推荐

0 条评论