1. Right-click the toolbar, select items, add COM components, and browse c: \ windows \ system32 \ macromed \ Flash to add the corresponding flash OCX.
2. Drag the Shockwave Flash Object Control in the toolbar to the interface.
3. Background setting code
Public form1 ()
{
Initializecomponent ();
This. axshockwaveflash1.movie = application. startuppath + "\ ee1e.swf ";
This. axshockwaveflash1.play ();
Axshockwaveflash1.flashcall + = new axshockwaveflashobjects. _ ishockwaveflashevents_flashcalleventhandler (flash_flashcall );
}
4. Add an as event in flash:
Select the button, right-click the action, and add the script as follows:
On (Release)
{
Import flash. External .*;
Externalinterface. Call ("test", "btn1 ");
}
Select another button and repeat the above operation to change "btn1" to "btn2"
5. Return to the C # program and add the following code in Step 1:
Void flash_flashcall (Object sender, axshockwaveflashobjects. _ ishockwaveflashevents_flashcallevent E)
{
String S = nodexml (E. Request. tostring () [0]. childnodes [0]. innertext. tostring ();
Switch (s)
{
Case "btn1 ":
This. label1.text = s;
Break;
Case "btn2 ":
This. label1.text = s;
Break;
Default:
Break;
}
Throw new exception ("Flash event error .");
}
Private xmlnodelist nodexml (string S)
{
Xmldocument Doc = new xmldocument ();
Doc. loadxml (s );
Xmlnodelist list = Doc. getelementsbytagname ("arguments ");
Return list;
}
Place a lable on the interface and click the button to view the result.