AS2和AS3之间的通信 [英] communication between as2 and as3

查看:293
本文介绍了AS2和AS3之间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个$ C $下一个按钮,在as2.swf

I have this code under a button in 'as2.swf'

on (release) {
unloadMovie(this);  
}

和这个SWF被加载到被称为的main.swfAS3容器,但是当我preSS它什么也没有发生,文件不卸载本身。任何一个可以见识一下吗?

and this swf is being loaded into as3 container called 'main.swf', but when i press it nothing happens and the file does not unload itself. any one can enlighten me on that?

推荐答案

ActionScript 3的使用AVM2虚拟机,而ActionScript 2的使用较早的AVM。这意味着,他们不在同一沙箱中。因此,两者之间的通信是非常困难的。

ActionScript 3 uses the AVM2 virtual machine while ActionScript 2 uses the older AVM. This means that they are not in the same sandbox. Thus communication between the two is difficult at best.

AVM2(AS3)可以装载和AVM1(AS2),但AVM1着负载AVM2工作。

AVM2(as3) can load and work with AVM1(as2) but AVM1 cant load AVM2.

下面是如何在两者之间沟通的一个例子:

Here is an example of how to communicate between the two:

AS3示例:

import flash.net.LocalConnection;
import flash.display.Stage;

var receiverLC:LocalConnection = new LocalConnection()

receiverLC.connect("__myConnection");

receiverLC.client = this;  

var request:URLRequest = new URLRequest("as2Movie.swf");

var loader:Loader = new Loader();

loader.load(request);

mainLoader_mc.addChild(loader);
. 
function changeSpeed(speed:Number):void {

stage.frameRate=speed

}

AS2示例:

var sending_lc:LocalConnection=new  LocalConnection()

function changeSpeed(num:Number){

sending_lc.send("__myConnection", "changeSpeed",num);

}

关键的是,AS2必须通过命令回AS3 - 关键是这一行:

The key is that the AS2 must pass commands back to AS3 - the key is this line:

sending_lc.send("__myConnection", "changeSpeed",num);

而不是依赖于AS2行动

所以,把你的行动,以AS3的容器。

So instead of relying on AS2 actions, send your actions to the AS3 container.

这是例子: http://flashgosu.com/?tag = AS2到AS3-AVM1到AVM2

这篇关于AS2和AS3之间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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