【发布时间】:2010-04-26 13:40:35
【问题描述】:
编辑:由于答案,我更改了发布的代码。我已经添加了 Security.allowDomain("*") 行,那行给我一个错误。那么,如何制作呢?
我想将 Action Script 3.0 应用程序运行到 Flex 应用程序中。为此,我做了以下工作:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication windowComplete="loadSwfApplication()" xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
private function loadSwfApplication()
{
// The next line throws me an error.
Security.allowDomain("*");
var urlRequest:URLRequest = new URLRequest("path/to/the/application.swf");
swfLoader.addEventListener(Event.COMPLETE, loadComplete);
swfLoader.load(urlRequest);
}
private function loadComplete(completeEvent:Event)
{
var swfApplication:* = completeEvent.target.content;
swfApplication.init(); // this is a Function that I made it in the Root class of swfApplication
}
]]>
</mx:Script>
<mx:SWFLoader id="sfwLoader"/>
</mx:WindowedApplication>
问题是在调用swfApplication.init(); 时,AIR Player 会抛出异常:
安全沙盒违规:调用方文件:///path/to/the/application.swf 无法访问 app:/SWFApplicationLoader.swf 拥有的 Stage。
这是因为在application.swf的某处我使用这样的舞台:
if (root.stage != null)
root.stage.addEventListener(Event.REMOVED, someFunction);
root.stage.stageFocusRect = false;
如何加载此 swf 应用程序并毫无问题地使用舞台?
【问题讨论】:
标签: actionscript-3 flash air flex4