以下代码是帧脚本(选中某帧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>"));