Reloading and updating flash files inside the window form

Using DOTNET 3.5. I have an application that shows loading a flash movie in a form using this code

axShockwaveFlash1 = new AxShockwaveFlashObjects.AxShockwaveFlash () axShockwaveFlash1.LoadMovie (0, Form1.currentGame);

The problem is that whenever I make changes to the flash memory located in our application and try to update it to see the changes, the new changes are "mixed up". to be more specific, it seems that the background and some controls of the previous flash still remain, “spoil” the loaded new flash memory. why?

Using the following methods before downloading, the second flash video doesn't matter

axShockwaveFlash1.Refresh (); axShockwaveFlash1.Stop ();

+3
source share
3 answers

Have you tried to download a "blank" flash video before uploading a new video?

eg.

axShockwaveFlash1.LoadMovie(0,"");

I am sure I encountered a similar problem and solved it this way.

+1
source

Try it. Make an empty swf. "Blank.swf" first downloads it and then reloads your game.

axShockwaveFlash1.LoadMovie(0,"Blank.swf");
axShockwaveFlash1.Play();
axShockwaveFlash1.LoadMovie(0, Form1.currentGame);
axShockwaveFlash1.Play();

Make sure you provide the correct path for Blank.swf .

+1
source

, . .

private void btnReload_Click(object sender, EventArgs e)
    {
        byte[] fileContent = File.ReadAllBytes(Application.StartupPath + @"\yourflashfile.swf");

        if (fileContent != null && fileContent.Length > 0)
        {
            using (MemoryStream stm = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stm))
                {
                    /* Write length of stream for AxHost.State */
                    writer.Write(8 + fileContent.Length);
                    /* Write Flash magic 'fUfU' */
                    writer.Write(0x55665566);
                    /* Length of swf file */
                    writer.Write(fileContent.Length);
                    writer.Write(fileContent);
                    stm.Seek(0, SeekOrigin.Begin);
                    /* 1 == IPeristStreamInit */
                    //Same as LoadMovie()
                    this.axShockwaveFlash1.OcxState = new AxHost.State(stm, 1, false, null);
                }
            }

            fileContent = null;
            GC.Collect();
        }
    }

- SO, .

+1

Source: https://habr.com/ru/post/1768831/


All Articles