可以在AS2瑞士法郎装载到AS3瑞士法郎?我如何添加这个舞台上,并用它从AS3 SWF互动? [英] Can an AS2 swf be loaded into an AS3 swf? How can I add this to the stage and interact with it from As3 swf?

查看:322
本文介绍了可以在AS2瑞士法郎装载到AS3瑞士法郎?我如何添加这个舞台上,并用它从AS3 SWF互动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载写在AS2到AS3 SWF中的SWF - 使用Loader类和侦听引发Event.COMPLETE。在我的onCompleteHandler功能,我想它添加到舞台让我试着 -

I am trying to load a swf written in AS2 into an AS3 swf - using Loader class and listening for Event.COMPLETE. in my onCompleteHandler function i want to add this to the stage so Im trying -

addChild(evt.currentTarget.content)

...但我得到了以下错误消息:

... but I get the following error message:

Error #2180: It is illegal to move AVM1 content (AS1 or AS2) to a different part of the displayList when it has been loaded into AVM2 (AS3) content.

在AS2 swwf有很多code,我真的不希望有迁移到AS3,如果我能避免它。任何人都知道这是可能的或知道的不同的充方式加载的SWF添加到舞台。我怎么那么去调用函数中加载的SWF?

The AS2 swwf has a lot of code and I really dont want to have to migrate to AS3 if I can avoid it. Anybody know if this is possible or know of a differnt way to add the loaded swf to the stage. How do I then go about calling functions in the loaded swf?

下面是一个code片段 -

Here is a code snippet -

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
var request:URLRequest = new URLRequest("testLoadSwf.swf");
loader.load(request);

function onCompleteHandler(evt:Event) {
   addChild(evt.currentTarget.content);
}

谢谢大家。

推荐答案

做到这一点的唯一真正有效的方法是使用的LocalConnection。 AS2和AS3不能相互通信得多。如果您仍然可以访问AS2文件的源代码,可以公开某些功能的LocalConnection。还有格兰特斯金纳需要一些基础的出这样做的整齐的辅助类叫SWFBridge,它可在这里:的 http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html

The only really effective way to do this is by using LocalConnection. AS2 and AS3 can't communicate much with each other. If you still have access to the AS2 file's source, you can expose some functions with LocalConnection. There's also a neat helper class by Grant Skinner called SWFBridge that takes some of the groundwork out of doing this, it's available here: http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html

这篇关于可以在AS2瑞士法郎装载到AS3瑞士法郎?我如何添加这个舞台上,并用它从AS3 SWF互动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆