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