在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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" /> </mx:Application> 点下Flex中的button时的情况: 点下C#中的button时的情况: |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论