简体   繁体   English

使用AS3在本地加载XML

[英]Loading XML locally with AS3

I have a project in Flash Builder and I use Bulkloader to load some configuration files. 我在Flash Builder有一个项目,我使用Bulkloader来加载一些配置文件。 When I run the project from Flash Builder or in a server, everything works as expected, but when I run the SWF from another location (for example "my documents"), the project can't load the XML. 当我从Flash Builder或服务器运行项目时,一切都按预期工作,但是当我从另一个位置运行SWF(例如“我的文档”)时,项目无法加载XML。

I'm not sure if this is a security problem or something similar. 我不确定这是安全问题还是类似问题。

Thanks in advance! 提前致谢!

You need to use this settings manager to add locations that are safe for your SWF to access data from. 您需要使用此设置管理器添加SWF安全访问数据的位置。

It should end up looking something like this: 最终应该看起来像这样:

在此输入图像描述

Use the Add location feature to add the drive that your My Documents folder is contained within. 使用“ 添加位置”功能添加包含“ 我的文档”文件夹的驱动器。

Assuming that you are developing a WebApplication and not an AIR desktop application, you are allowed to access either network files or local files, but not the both of them. 假设您正在开发WebApplication而不是AIR桌面应用程序,则可以访问网络文件或本地文件,但不能同时访问它们。 When you run from FlashBuilder, your program is executing from a SandBox and such restrictions won't apply, how ever when you deploy outside, you will get a security error. 当您从FlashBuilder运行时,您的程序正在从SandBox执行,并且此类限制将不适用,无论您何时在外部部署,都会出现安全性错误。

If your application does not need to use any network features, you can specify use-network=false as part of the compiler options which will allow you to access local files. 如果您的应用程序不需要使用任何网络功能,则可以指定use-network=false作为编译器选项的一部分,这将允许您访问本地文件。

To add/change Compiler options, Right click on your project in Flash Builder, select Properties, then Flex Compiler, and enter the option in Additional Compiler arguments. 要添加/更改编译器选项,请在Flash Builder中右键单击项目,选择“属性”,然后选择“Flex编译器”,并在“其他编译器”参数中输入选项。 (I am using Flex Builder 3, so it might be different on the Flash Builder that you are using) (我使用的是Flex Builder 3,因此您使用的Flash Builder可能会有所不同)

Flex Compiler Options Flex编译器选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM