c# winform as3相互调用

2020-12-13 13:44

阅读:558

        //接收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("" +
                this.textBox1.Text + "
");
        }

        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交互


评论


亲,登录后才可以留言!