我可以通过axShockwaveFlash
对象将swf文件加载到我的C#程序中,但我必须通过用户按钮单击关闭它。
我尝试了所有可能的代码,但没有一个工作。
axShockwaveFlash1.Movie = "";
axShockwaveFlash1.Movie = string.Empty;
axShockwaveFlash1.Movie = null;
axShockwaveFlash1.Playing = false;
您是否知道如何“卸载”swf文件?
答案 0 :(得分:4)
只需从Windows窗体控件集合中删除Flash控件即可。以下是我实现此方法的方法(下面的代码经过测试并且运行正常):
public partial class Form1 : Form
{
private AxShockwaveFlashObjects.AxShockwaveFlash axFlash;
public Form1()
{
InitializeComponent();
axFlash = new AxShockwaveFlashObjects.AxShockwaveFlash();
axFlash.BeginInit();
axFlash.Location = new Point(50, 50);
axFlash.Name = "Load/unload test";
axFlash.TabIndex = 0;
axFlash.EndInit();
}
private void startButton_Click(object sender, EventArgs e)
{
axFlash = new AxShockwaveFlashObjects.AxShockwaveFlash();
axFlash.BeginInit();
axFlash.Location = new Point(50, 80);
axFlash.Name = "Test Movie";
axFlash.TabIndex = 0;
axFlash.Size = new Size(640, 480);
axFlash.EndInit();
this.Controls.Add(axFlash);
axFlash.LoadMovie(0, @"C:\Movies\MyMovie.swf");
}
private void unloadButton_Click(object sender, EventArgs e)
{
this.Controls.Remove(axFlash);
}
}