【问题标题】:Load an image in flash/actionscript from a different origin domain从不同的源域加载 Flash/actionscript 中的图像
【发布时间】:2012-09-18 22:37:17
【问题描述】:

在 Flash 编码方面,我完全是个菜鸟。

我有一个从 S3 资产存储桶加载的 flash swf 文件。在 Flash swf 中它应该显示一个“浏览”按钮,图片也由同一个存储桶提供。当我从站点所在的同一域托管图像和 swf 文件时,这可以正常工作,但从 S3 加载时则不行。

我已将crossdomain.xml 文件添加到资产存储桶中,如下所示(我正在尝试使用 '*' 开始只是为了让它工作,并在它似乎正在做任何事情时将其缩小到我的实际主机):

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <allow-access-from domain="*"/>
</cross-domain-policy>

我在存储桶中还有一个跨域资源共享配置,以便为我们的样式表正确加载字体(这是有效的)。

使按钮图像加载到动作脚本中我做错了什么?我是否需要修改 actionscript 代码本身?代码位于此处(任何人都可以使用的公共图书馆,不是我创作的):s3-swf-upload-plugin

您可以看到here 正在实例化一个新的browseButton 定义here。就像我说的我对actionscript并不完全熟悉,但如果有人能告诉我出了什么问题,我相信我可以摸索它:) 什么是获得实际错误报告的好方法? Firefox 和 Chrome 控制台中的 Firebug 没有任何来自 Flash 的关于正在发生的错误的消息。

编辑:

在设置 flash 对象和设置按钮图像的路径时发生了一些奇怪的事情。我更新了BrowseButton.as 来做到这一点:

Security.loadPolicyFile("http://s3.amazonaws.com/my-bucket/crossdomain.xml");

我把它放在BrowseButton() 函数中的任何URLRequest 调用之前。但是它仍然没有显示图像:(我还将 URLRequest 中的值硬编码为:

upLoader.load(new URLRequest("http://s3.amazonaws.com/my-bucket/assets/s3_up_button.gif"));

但似乎什么也没发生。当我将其设置为/assets/s3_up_button.gif 以从本地文件中提取时,它工作正常。我究竟做错了什么!如何从 Flash 视频中获取错误消息? :\ 我使用&lt;debug&gt;true&lt;/debug&gt; 编译,但我不确定如何获取实际的异常消息。

【问题讨论】:

标签: actionscript-3 flash amazon-s3 cross-domain


【解决方案1】:

检查您的 swf 位于哪个沙箱中:

Security.sandboxType 属性

SWF 文件的作者可以使用只读静态 Security.sandboxType 属性来确定沙箱的类型 哪个 Flash Player 分配了 SWF 文件。安全类 包括表示可能值的常量 Security.sandboxType 属性,如下:

Security.REMOTE--The SWF file is from an Internet URL, and operates under domain-based sandbox rules.
Security.LOCAL_WITH_FILE--The SWF file is a local file, but it has not been trusted by the user and was not published with a networking designation. The SWF file can read from local data sources but cannot communicate with the Internet.
Security.LOCAL_WITH_NETWORK--The SWF file is a local file and has not been trusted by the user, but it was published with a networking designation. The SWF can communicate with the Internet but cannot read from local data sources.
Security.LOCAL_TRUSTED--The SWF file is a local file and has been trusted by the user, using either the Settings Manager or a Flash Player trust configuration file. The SWF file can both read from local data sources and communicate with the Internet.

您可能需要Security.LOCAL_WITH_NETWORK,尽管Security.LOCAL_TRUSTED 也可以。

这里有解释以及如何在 Flex 中设置沙箱的详细信息:http://livedocs.adobe.com/flex/3/html/help.html?content=05B_Security_04.html

如果您在 Flash IDE 中工作,它应该只是发布设置的一部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    • 2013-03-16
    • 2016-09-14
    • 1970-01-01
    相关资源
    最近更新 更多