我可以通过axShockwaveFlash对象将swf文件加载到C#程序中,但是必须通过单击用户按钮将其关闭。
我尝试了以下所有可能的代码,但没有一个起作用。

axShockwaveFlash1.Movie = "";
axShockwaveFlash1.Movie = string.Empty;
axShockwaveFlash1.Movie = null;
axShockwaveFlash1.Playing = false;


您是否有办法“卸载” SWF文件?

最佳答案

只需从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);
    }
}

10-07 17:14