如何在 Flex4 中加载并运行 Flex3 SWF,反之亦然?
我有兴趣了解如何在 Flex-4 SWF 中运行 Flex-3 SWF。
我的 Flex-4 主机应用程序如下所示:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<mx:SWFLoader source="SimpleFlex3App.swf" loadForCompatibility="true"/>
</s:Application>
这是 Flex-3 应用程序:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="400">
<mx:Script>
<![CDATA[
private function onClick():void
{
labelField.visible = true;
}
]]>
</mx:Script>
<mx:Button label="Click Me" click="onClick();" horizontalCenter="0" verticalCenter="-20"/>
<mx:Label text="Clicked" visible="false" id="labelField" horizontalCenter="0" verticalCenter="20"/>
</mx:Application>
我在 SWFLoader 尝试设置桥的位置处获得一个空对象引用。我假设它没有获得 IMarshalSystemManager 实现的实例。
IMarshalSystemManager(sm.getImplementation("mx.managers::IMarshalSystemManager")).addChildBridge(_swfBridge, this);
通过使用 SWFLoader 并将 loadForCompatibility 设置为 true,我遵循了 adobe 文档:
我必须错过了一些非常简单的事情,因为我的主机和托管应用程序基本上不做任何特别的事情。
此外,是否可以采取相反的做法,在 Flex-3 中运行基于 Flex-4 的 SWF?在我看来,adobe 文档并没有明确表示是或否。
谢谢。
I am interested in understanding how to run a Flex-3 SWF inside a Flex-4 SWF.
My Flex-4 host app looks like this:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<mx:SWFLoader source="SimpleFlex3App.swf" loadForCompatibility="true"/>
</s:Application>
And this is the Flex-3 app:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="400">
<mx:Script>
<![CDATA[
private function onClick():void
{
labelField.visible = true;
}
]]>
</mx:Script>
<mx:Button label="Click Me" click="onClick();" horizontalCenter="0" verticalCenter="-20"/>
<mx:Label text="Clicked" visible="false" id="labelField" horizontalCenter="0" verticalCenter="20"/>
</mx:Application>
I get a null object reference where the SWFLoader tries to set up the bridge. I assume it does not get an instance for the IMarshalSystemManager implementation.
IMarshalSystemManager(sm.getImplementation("mx.managers::IMarshalSystemManager")).addChildBridge(_swfBridge, this);
By using the SWFLoader and setting loadForCompatibility to true I was following the adobe documentation:
I must be missing out on something very simple as both, my host and hosted apps, basically don't do anything special.
Further, is it possible to do the opposite and run a Flex-4 based SWF inside a Flex-3 one? In my opinion the adobe doc does not clearly say yes or no.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Flex harUI 在 adobe 论坛提供了正确的答案。
谢谢!
Flex harUI provided the correct answer here at the adobe forum.
Thanks!
这是可能的,因为我构建了一个可以将 AS2 swf 加载到 Flex 3 SWF 中的应用程序。
您可能需要将 trustContent 属性设置为 false。这意味着您的 swf 位于不同的安全域中,并且两者之间的通信需要通过共享事件桥、本地连接或自定义套接字进行。
请查看此处,了解有关此 http: //www.pixelbox.net/2009/02/11/sub-application-communication-in-air/
It is possible to do as I built an application that can load AS2 swfs into a Flex 3 SWF.
You may need to set the trustContent property to false. This will mean you swfs are in separate security domains, and communication between the two will need to happen over a shared event bridge, local connection or custom sockets.
Have a look here for more info on this http://www.pixelbox.net/2009/02/11/sub-application-communication-in-air/