F-IN-BOX .NET Help >> How to

Embedding swflash.ocx/flash.ocx code into application

Traditionally, there are many obstacles or annoyances that one will encounter when using Macromedia Flash Player ActiveX in an application.

The Application...

  1. needs swflash.ocx/flash.ocx installed in the system before it will work.
  2. has to work flawlessly with the already installed version of the Macromedia Flash Player ActiveX.
  3. has no easy way to prevent flash movies from being abused.

F-IN-BOX to the rescue. It solves these problems and more!

By default, the component will use the swflash.ocx/flash.ocx that's already installed on the system. The component can alternatively use any swflash.ocx/flash.ocx that you would like to provide it with using any supported source. An example of this how you can embed the flash.ocx into the resource section of your application's exe file and then load it at runtime. Using this method, your application will work even if the Macromedia Flash Player ActiveX doesn't exist on the target system. With F-IN-BOX, hassling around with Macromedia Flash Player ActiveX installation issues are a thing the past! It's so easy to do! There are even demos provided which come complete with source code to prove it!

Here's an example of how to load swflash.ocx/flash.ocx code from a resource:

[ C# ]
private f_in_box__lib.f_in_box__control f_in_box__control1;
...

private void MainForm_Load(object sender, System.EventArgs e)
{
	// Loads flash.ocx from resource
	System.IO.Stream StreamWithFlashOCXCode = 
          System.Reflection.Assembly.GetExecutingAssembly().
             GetManifestResourceStream("Sample3_StandalonePlayer.flash_ocx.flash.ocx");

	if (StreamWithFlashOCXCode == null)
	{
		System.Windows.Forms.MessageBox.Show("Resource 'Flash.ocx' not found");
		return;
	}

	f_in_box__lib.AxCode code = new f_in_box__lib.AxCode(StreamWithFlashOCXCode);

	f_in_box__control1 = new f_in_box__lib.f_in_box__control(code);

	Controls.Add(f_in_box__control1);
}

[ VB.Net ]
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
      Handles MyBase.Load

   'Loads flash.ocx from resource
   Dim StreamWithFlashOCXCode As System.IO.Stream = _
      Me.GetType().Assembly._
         GetManifestResourceStream("Sample3_StandalonePlayer.flash.ocx")

   If StreamWithFlashOCXCode Is Nothing Then
      MsgBox("Resource 'Flash.ocx' not found")
   End If

   Dim code As New f_in_box__lib.AxCode(StreamWithFlashOCXCode)

   f_in_box__control1 = New f_in_box__lib.f_in_box__control(code)
End Sub


Copyright © Softanics. All rights reserved.
F-IN-BOX is a trademark of Softanics.
Macromedia and Shockwave Flash are trademarks of Adobe