我在VC里加入这个ocx控件."Shockwave   Flash   Object,请问我要想在vc发送字符串给flash里面的文本框该怎么传?VC又如何获取到flash文本里的值?望大家多多指教!

解决方案 »

  1.   

    flash传递信息给vc,用fscommand
    比如在flash里调用vc退出,可以这样
    fscommand("bt", "exit");
    在VC中
    void CMasDlg::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args) 
    {
    if(strcmp(command,"bt")==0){
    if(strcmp(args,"exit")==0){
    ::PostQuitMessage(0);
    }
    }
    }
    注意Shockwaveflash1是ocx名
      

  2.   

    可以用Callfunction
    主程序端:flash1.LoadMovie(0,Application.StartPath+"\showstring.swf");
    CString temp="Helloworld";
    flash1.CallFunction("<invoke name=\"test\" returntype=\"xml\"><arguments><string>" + temp + "</string></arguments></invoke>");
    其中的text是在FLASH端注册的方法,<string>" + temp + "</string>中的temp是你传过FLASH端的参数,也就是你想传过去的参数,如果你想传多个参数,你可以添加多个<string></string>节点,中间放上你要传过去的参数,注意一点的是,<string>" + temp + "</string>,temp与+号之间要空格,否则你传不过去,还要注意,在FLASH端要用到一句话来注册 text方法,
    如下:
    flash.external.ExternalInterface.addCallback("test", this, test);
    否则,VC端就调用不到的flash端:
    ①添加一个文本框text_txt以显示效果或用trace("call: "+result+"")
    ②ActionScript代码为,其中result只是参数,而主程序端使用AS的函数时不需要关心参数名,只有知道有参数个数,或参数位置
    function test(result:Object):Void{
       test_txt.text=result;
    }
    flash.external.ExternalInterface.addCallback("test", this, test);