I assume what you are wanting to do is initialize this in C# rather than in Flash itself. It can be done but there are limitations to doing it (for example you may get weird security issues). Another caveat is this has only been tested on VS 2010/Flash 10 but it should work in any version in theory.
Okay, let us assume you have used the standard mechanism to put your flash control on the form. Also add the flash file you want to the resources (or an inline byte array, up to you).
Then use the following code to load the flash file.
private void InitFlashMovie(AxShockwaveFlash flashObj, byte[] swfFile)
{
using (MemoryStream stm = new MemoryStream())
{
using (BinaryWriter writer = new BinaryWriter(stm))
{
/* Write length of stream for AxHost.State */
writer.Write(8 + swfFile.Length);
/* Write Flash magic 'fUfU' */
writer.Write(0x55665566);
/* Length of swf file */
writer.Write(swfFile.Length);
writer.Write(swfFile);
stm.Seek(0, SeekOrigin.Begin);
/* 1 == IPeristStreamInit */
flashObj.OcxState = new AxHost.State(stm, 1, false, null);
}
}
}
Pass the form's flash object and the byte array containing the flash file to load and it should work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…