惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
IT之家
IT之家
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
C
Check Point Blog
T
Tailwind CSS Blog
博客园 - Franky
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
博客园 - 叶小钗
J
Java Code Geeks
腾讯CDC
罗磊的独立博客
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
B
Blog
V
Visual Studio Blog
F
Fortinet All Blogs

博客园 - 释天

4年后新的开始 flash make things move 电子书 破解pubwin ep html学习笔记(-) js学习笔记(-) - 释天 - 博客园 flex2注册码 flash与.net的联合开发(c#,c++)请大家讨论一下 flash中三维动画学习(关于类) flash中一个二维的类 经典言论 c#解答题参考答案 [求教]vs2005下关于css的问题 一个关于文件操作的类(功能还是有点弱) 写了个烂代码,请原谅 C#中接口(interface)的理解 赠送gmail邀请 三个范式的解释 Gridview的使用 iframe的使用
Flex2.0和C#间的通信[转] - 释天 - 博客园
释天 · 2006-11-05 · via 博客园 - 释天
 

http://blog.ezse.com/trackback.asp?tbID=299
C#的代码:

程序代码 程序代码

        private void button1_Click(object sender, EventArgs e)
        {
            String request = "<invoke name=\"testExternalAPI\" returntype=\"xml\"><arguments><string>Sent by C#</string></arguments></invoke>";
            try
            {
                this.flashResponse_txt.Text = this.flashControl.CallFunction(request);
            }
            catch 
            {
                this.flashResponse_txt.Text = e.ToString();
            }
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            String swfPath =  @"M:\ECX\FLASH\bin\Desktop.swf";
            this.flashControl.LoadMovie(0, swfPath);

        }

        private void flashControl_FlashCall(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
        {
            this.flashRequest_txt.Text = e.request;
            MessageBox.Show(e.request);
            this.flashControl.SetReturnValue("<string>C# Return 的内容</string>");

        }

Flex 的代码:

程序代码 程序代码

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="800" height="600" applicationComplete="init()">
    <mx:Script>
        <![CDATA[
            //import RP.Comm;
            function init():void {
                ExternalInterface.addCallback("testExternalAPI", tst);
            }
            
            
            
            function test():void{
                lblTest.text = ExternalInterface.call("testSentCSharp", "这里可以添加传入的参数");
                return;
            }

        function tst(paramTxt:String):String {
            lblTest.text = paramTxt;
            return "这是来自Flex的Return";
        }
            
        ]]>
    </mx:Script>

        <mx:Button x="117" y="114" label="Button" click="test()"/>
        <mx:Label x="19" y="10" text="abc" id="lblTest"/>
    </mx:Application>

点下Flex中的button时的情况:

点下C#中的button时的情况: