zoukankan      html  css  js  c++  java
  • c# winform as3相互调用

    C#主要代码:

    首先要添加COM组件-Shockwave Flash Object

            //接收flash发送过来的信息
            private void axShockwaveFlash1_FlashCall(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(e.request);

                XmlNodeList list = document.GetElementsByTagName("arguments");
                LoadTitleAndAuthor(Convert.ToString(list[0].FirstChild.InnerText), Convert.ToString(list[0].ChildNodes[1].InnerText));
            }
            public void LoadTitleAndAuthor(string title, string author)
            {
               textBox2.Text=title + "," + author;
            }
            //向flash发送信息
            private void sendToFlash_Click(object sender, EventArgs e)
            {
                this.axShockwaveFlash1.CallFunction("<invoke name="loadMsg" returntype="xml"><arguments><string>" +
                    this.textBox1.Text + "</string><string>男<string></arguments></invoke>");
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                this.axShockwaveFlash1.Movie = Application.StartupPath + "/未命名-4.swf";
            }

    flash文件主要代码as2.0:

    接收有C#发送过来的消息

    import flash.external.ExternalInterface;

    ExternalInterface.addCallback("loadMsg",null,loadMsg);

    function loadMsg(t1:String,t2:String):Void{
            txtName.text=t1;
      txtAge.text=t2;
     }

    向C#窗体发送消息:

    on(release)
    {
     import flash.external.ExternalInterface;
     //trace("metadata received");
     ExternalInterface.call("loadMsg", txtName.text,txtAge.text);
    }

    C#与flash as3.0交互

    as3.0 类文件编写 

    package{
        import flash.display.*;
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.utils.getDefinitionByName;
        import flash.external.ExternalInterface;
        import flash.text.*;

        public class Clas extends MovieClip
        {
            public function Clas()
            {
                btnsend.addEventListener(MouseEvent.CLICK,onclick);
                ExternalInterface.addCallback("setTxt",setTxt);
            }
            
            public function onclick(evt:MouseEvent){
                ExternalInterface.call("toTxt",this.txtsend.text);
            }
            
            public function setTxt(s:String,s2:String)
            {
                this.txtmsg.text=s+"-"+s2;
            }
        }
        
        
        } 

     C#代码的编写与as2.0通信的一样。

    http://www.cnblogs.com/Xingsoft-555/archive/2010/05/09/1731221.html

  • 相关阅读:
    HDU1285-确定比赛名次(拓扑排序)
    ftp sftp
    Python with 用法
    odoo 非root用户运行不成功
    linux 删除软连接
    vscode wsl php
    WSL 修改默认登录用户为root
    WSL ssh服务自启动
    odoo 获取model的所有字段
    odoo 在"动作"("Action")菜单中添加子菜单, 点击子菜单弹窗自定义form
  • 原文地址:https://www.cnblogs.com/lvcha/p/4054314.html
Copyright © 2011-2022 走看看