1、工具栏 》右键 》选择项 》添加COM组件 》 浏览 C:\Windows\System32\Macromed\Flash 对应的FLASH OCX 添加。
2、把工具栏中 Shockwave Flash Object 控件,拖到界面中。
3、后台设置代码
public
Form1()
{
InitializeComponent();
this .axShockwaveFlash1.Movie = Application.StartupPath + " \\ee1e.swf " ;
this .axShockwaveFlash1.Play();
axShockwaveFlash1.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(flash_FlashCall);
}
{
InitializeComponent();
this .axShockwaveFlash1.Movie = Application.StartupPath + " \\ee1e.swf " ;
this .axShockwaveFlash1.Play();
axShockwaveFlash1.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(flash_FlashCall);
}
4、在FLASH添加AS事件:
选中按钮,右键 》动作 》加入脚本如下
on
(release)
{
import flash.external. * ;
ExternalInterface.call ( " test " , " btn1 " );
}
{
import flash.external. * ;
ExternalInterface.call ( " test " , " btn1 " );
}
再选择一个按钮,重复上面操作,把里面的"btn1"改成"btn2"
5、回到c#程序,在第3步的代码下,添加如下代码:
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事件出错. " );
}
private XmlNodeList nodeXml( string s)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(s);
XmlNodeList list = doc.GetElementsByTagName( " arguments " );
return list;
}
{
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事件出错. " );
}
private XmlNodeList nodeXml( string s)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(s);
XmlNodeList list = doc.GetElementsByTagName( " arguments " );
return list;
}
界面上扔个lable,点按钮看效果。