C # WinForm AS3 call each other

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.