views:

455

answers:

2

hi guys,
i was wonder if there is any way one can read-write (or save/load) AxShockwaveFlash Flash Object to a (binary/text)file?

I have a Winform with AxShockwaveFlash Flash Object on it and want it to be save to a
file ,but serialization doesnt not work as type AxShockwaveFlash is not marked for Serialization?
(Basically trying to dynamically write .swf to file.)

Any ideas??

Thanks and regards
Amit

+1  A: 

Hi Amit I think this link is useful for you;
Serialize Flash object

Try the sample provided on this link.

Vijay Balkawade
+1  A: 

Hi guys,

i tried this and it worked for me.

I dervied a class from AxShockwaveFlashObjects.AxShockwaveFlash and implemented ISerializable interface.

Implemented GetObjectData and serialization constructor . not much coding in them.

[Serializable()]
class MyCustomFlash : AxShockwaveFlashObjects.AxShockwaveFlash, ISerializable
{
    public MyCustomFlash()
    {

    }

    public MyCustomFlash(SerializationInfo info, StreamingContext ctxt)
    {
       //dont think this is required.
        this.OcxState = (State)info.GetValue("ocxstate", typeof(State));              

    }

    #region ISerializable Members
    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
       //dont think this is required.
       // info.AddValue("movie", this.Movie);
        info.AddValue("ocxstate", this.OcxState);
    }
    #endregion
}

I was using winform. so ensure that you Embed the movie using

    axShockwaveFlash1.EmbedMovie = true;
   //loadMovie follows

Then try Normal binary serialization/deserilzation.

During deserialization , i tried to add the serialized flash to another form.
But keep getting AxHost+InvalidActiveXStateException and the control didnt appear on form . i think the control was not inited on the form.
Just copy designer initialsation code to it .and then it works.

           string serialFilePath = @"E:\test\serialFiles\DataFile.dat";               
            FileStream myFS = new FileStream(serialFilePath, FileMode.Open);
            // Create a binary formatter object to deserialize the data
            BinaryFormatter myBF = new BinaryFormatter();

            MyCustomFlash flashObj;
          //where class MyCustomFlash : AxShockwaveFlashObjects.AxShockwaveFlash, ISerializable

            flashObj = (MyCustomFlash)myBF.Deserialize(myFS);
           //this is code from VS designer..need to initialise flash control
            ((System.ComponentModel.ISupportInitialize)(flashObj)).BeginInit();
            myFS.Close();
            flashObj.Enabled = true;
            this.Controls.Add(flashObj);
            ((System.ComponentModel.ISupportInitialize)(flashObj)).EndInit();

            flashObj.Name = "Axflash";
            flashObj.Visible = true;
            flashObj.Location = new System.Drawing.Point(12, 12);
            flashObj.Size = new System.Drawing.Size(309, 207);

Hope this helps :)

thx
amitd

Amitd