CR的代码文本

all for learning about the world
  订阅 订阅  :: 管理

AS2使用ExternalInterface

Posted on 2013-09-05 14:36  mumuliang  阅读(416)  评论(0编辑  收藏  举报

以下代码是帧脚本(选中某帧F9,粘贴)

import flash.external.ExternalInterface;

// 假的,目的是为了执行createButton里面的ExternalInterface.addCallback()
var fakeBtn:MovieClip = createButton();

function cppCommand(cmd:String)
{
    this.mcTxt.text = "recv: " + cmd.toString();
}

function createButton():MovieClip
{
    var depth:Number = this.getNextHighestDepth();
    this.createTextField("mcTxt", depth, 0, 0, 100, 30);
    this.mcTxt.text = "EI兼容性:"+ExternalInterface.available.toString();
    if(ExternalInterface.available)
    {
        ExternalInterface.addCallback("cppCommand",this,cppCommand);
    }
    return mc;
}

 cpp中

m_flashCtrl.CallFunction(_T("<invoke name=\"cppCommand\"><arguments><string>发点儿啥呢</string></arguments></invoke>"));