C # main code:
The first thing to add COM components-shockwave Flash Object
Receive information sent by 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;
}
Send a message to flash
private void Sendtoflash_click (object sender, EventArgs e)
{
This.axShockwaveFlash1.CallFunction ("<invoke name=\" loadmsg\ "returntype=\" xml\ "><arguments>< String> "+
This.textBox1.Text + "</string><string> male <string></arguments></invoke>");
}
private void Form1_Load (object sender, EventArgs e)
{
This.axShockwaveFlash1.Movie = Application.startuppath + "/unnamed -4.swf";
}
Flash file main code as2.0:
Receive a message from C # sent over
Import Flash.external.ExternalInterface;
Externalinterface.addcallback ("Loadmsg", null,loadmsg);
function Loadmsg (t1:string,t2:string): void{
TXTNAME.TEXT=T1;
Txtage.text=t2;
}
To send a message to a C # form:
On (release)
{
Import Flash.external.ExternalInterface;
Trace ("metadata received");
Externalinterface.call ("Loadmsg", Txtname.text,txtage.text);
}
C # interacts with Flash as3.0
as3.0 class file Writing
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 # code is written in the same way as as2.0 communication.
Http://www.cnblogs.com/Xingsoft-555/archive/2010/05/09/1731221.html
C # WinForm AS3 calls each other