What is F-IN-BOX .NET Edition?
F-IN-BOX is a .NET component that wraps the official Macromedia / Adobe Flash Player ActiveX (swflash.ocx / flash.ocx), allowing you to bypass its limitations while maintaining full compatibility. Unlike custom renderers, F-IN-BOX uses the real Flash engine but enables you to load SWF and FLV files directly from memory streams—without saving to disk or relying on temporary files.
It supports asynchronous streaming of large movies and external resources, frame capture, transparent Flash UI, audio control, and the External API for two-way communication between your app and the Flash content.
All Flash Player versions are supported, in both x86 and x64 architectures. No installation or registration of Flash Player is required—F-IN-BOX can even load it from resources.
Want to see F-IN-BOX in action?
Enter a valid email address to receive the demo version.
If you don't receive the email, please contact us.
Key Features
It is a well-known limitation that Flash Player ActiveX can only load movies from certain URLs. This means you must first extract the movie from your application's resources, save it to a temporary location, generate a corresponding URL, and then pass that URL to the Flash Player ActiveX. After playback, the temporary file should be deleted. This process is not only cumbersome but also unreliable—especially if the user lacks the necessary permissions or access to the temporary folder. Worse, it poses a security risk, as the temporary file could be intercepted.
Fortunately, there's a better way. F-IN-BOX uses a different approach: instead of relying on temporary files, it loads your movies directly into the Macromedia / Adobe Flash Player ActiveX control by wrapping the native swflash.ocx
/flash.ocx
. This method avoids all the drawbacks of temporary file handling. In addition, you can protect your movies from unauthorized access using your preferred software protection solution.
With F-IN-BOX, you can load any Flash movie directly from memory using the LoadMovieFromStream
or PutMovieFromStream
methods—no temporary files required. Load movies on the fly from any supported source. For example, you can embed one or more SWF files in your application's resource section and load them directly from the executable. That's the power and portability of F-IN-BOX!
Here's an example of how to load a Flash movie from a resource:
private void MainForm_Load(object sender, System.EventArgs e)
{
Stream MovieStream =
GetType().Assembly.
GetManifestResourceStream("Sample2_SWF_FLV_Embedding.Embedded_Movies.movie.swf");
f_in_box__control1.PutMovieFromStream(MovieStream);
f_in_box__control1.FlashMethod_Play();
}
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents f_in_box__control1 As f_in_box__lib.f_in_box__control
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim MovieStream As Stream = _
GetType().Assembly.GetManifestResourceStream("Sample1_SWF_Player.movie.swf");
f_in_box__control1.PutMovieFromStream(MovieStream)
f_in_box__control1.FlashMethod_Play()
End Sub
End Class
One of the biggest problems when using Flash Player ActiveX is the requirement to register the component. The typical approach involves saving swflash.ocx
or flash.ocx
to a temporary location and then registering it. This has clear drawbacks—insufficient permissions to write or register the file, for instance. With F-IN-BOX, you can forget about those limitations! F-IN-BOX can load swflash.ocx
/ flash.ocx
from any source. For example, you can embed the control directly in your application's resources and instruct F-IN-BOX to use it. No temporary files. No registration. No permission issues. F-IN-BOX loads and uses the control directly, giving you complete control over which version of swflash.ocx
to use—while defaulting to the system-registered version if you prefer.
Traditionally, developers face many headaches when working with the Macromedia / Adobe Flash Player ActiveX:
The application:
- Requires
swflash.ocx
/flash.ocx
to be installed system-wide. - Must be compatible with whatever version of the ActiveX control is already installed.
- Lacks built-in protection against unauthorized use or extraction of Flash content.
F-IN-BOX solves all of these issues—and more!
By default, it uses the system-installed version of swflash.ocx
, but it can also load any version you provide from any supported source. For example, you can embed swflash.ocx
into your application's executable and load it at runtime. This means your app can work even if Flash Player ActiveX isn't installed on the user's system. With F-IN-BOX, dealing with Flash Player installation is a thing of the past—it's incredibly simple and reliable.
Here's an example of how to load swflash.ocx
/ flash.ocx
directly from application resources:
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);
}
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
With F-IN-BOX, you can create applications based on transparent Flash movies, including non-rectangular and translucent forms. Use Flash to design a modern user interface, and implement your business logic using .NET.
To enable transparency, use the f_in_box__lib.f_in_box__form
component:
// MyTranslucencyForm inherits from f_in_box__lib.f_in_box__form
// Create a translucent form
MyTranslucencyForm FlashPlayerForm = new MyTranslucencyForm();
// Load the Flash movie from an embedded resource stream
System.IO.Stream MovieStream =
System.Reflection.Assembly.GetExecutingAssembly().
GetManifestResourceStream("Sample4_Translucency.Embedded_Movies.movie.swf");
FlashPlayerForm.PutMovieFromStream(MovieStream);
// Set the form size and position it in the center of the screen
FlashPlayerForm.Width = 400;
FlashPlayerForm.Height = 400;
FlashPlayerForm.Left =
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2 -
FlashPlayerForm.Width / 2;
FlashPlayerForm.Top =
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height / 2 -
FlashPlayerForm.Height / 2;
// Start playback...
FlashPlayerForm.FlashMethod_Play();
// ...and show the form
FlashPlayerForm.Show();
Application.Run(FlashPlayerForm);
' MyTranslucencyForm inherits from f_in_box__lib.f_in_box__form
' Create a translucent form
Dim FlashPlayerForm As New MyTranslucencyForm
' Load the Flash movie from an embedded resource stream
Dim MovieStream As System.IO.Stream = _
System.Reflection.Assembly.GetExecutingAssembly. _
GetManifestResourceStream("Sample4_Translucency.movie.swf")
FlashPlayerForm.PutMovieFromStream(MovieStream)
' Set the form size and position it in the center of the screen
FlashPlayerForm.Width = 400
FlashPlayerForm.Height = 400
FlashPlayerForm.Left = _
Screen.PrimaryScreen.WorkingArea.Width() / 2 - _
FlashPlayerForm.Width / 2
FlashPlayerForm.Top = _
Screen.PrimaryScreen.WorkingArea.Height() / 2 - _
FlashPlayerForm.Height / 2
' Start playback...
FlashPlayerForm.FlashMethod_Play()
' ...and show the form
FlashPlayerForm.Show()
Application.Run(FlashPlayerForm)
With F-IN-BOX, you can play Flash Video (FLV) from external files, URLs, or directly from a stream. When F-IN-BOX loads Flash Video, no temporary files are created—everything runs directly from memory. You can even encrypt your video and embed it into your application's resources—F-IN-BOX loads the FLV without ever writing it to disk.
To play Flash Video from memory, create a Flash movie that loads the video from a “private” URL (e.g., http://FLV/FlashVideo.flv
). The Flash movie should include the following ActionScript code (typically placed under a button):
var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var netStream:NetStream = new NetStream(netConn);
my_video.attachVideo(netStream);
netStream.setBufferTime(0);
netStream.play("http://FLV/FlashVideo.flv");
When Flash attempts to load the video from http://FLV/FlashVideo.flv
, F-IN-BOX provides the FLV content. Use the global OnLoadExternalResourceByFullPath
event handler to intercept and serve external resources. See the examples below:
// Register the handler
f_in_box__control1.AxCode.OnLoadExternalResourceByFullPath +=
new f_in_box__lib.AxCode.
OnLoadExternalResourceByFullPathEventHandler(OnLoadExternalResourceByFullPath);
private void OnLoadExternalResourceByFullPath(
object sender,
string URL,
System.IO.Stream Stream,
ref bool Handled)
{
if (URL == "http://FLV/FlashVideo.flv")
{
System.IO.Stream FLVStream =
this.GetType().Assembly.
GetManifestResourceStream("Sample2_SWF_FLV_Embedding.Embedded_Movies.flashvideo.flv");
const int size = 64 * 1024;
byte[] buffer = new byte[size];
int ReadBytes;
while ((ReadBytes = FLVStream.Read(buffer, 0, size)) > 0)
Stream.Write(buffer, 0, ReadBytes);
Stream.Close();
Handled = true;
}
}
Private Sub OnLoadExternalResourceByFullPath( _
ByVal sender As Object, _
ByVal URL As String, _
ByVal Stream As System.IO.Stream, _
ByRef Handled As Boolean _
)
If URL = "http://FLV/FlashVideo.flv" Then
Dim FLVStream As System.IO.Stream = _
Me.GetType().Assembly. _
GetManifestResourceStream("Sample2_SWF_FLV_Embedding.flashvideo.flv")
' You can write all content here, but if FLVStream is large,
' this operation may block the UI. For large files, consider
' writing to the stream in a background thread.
' See the Sample1_SWF_And_FLV_Player project for an example.
Const nSize = 64 * 1024
Dim buffer(nSize) As Byte
Dim nReadBytes As Integer
While True
nReadBytes = FLVStream.Read(buffer, 0, nSize)
If nReadBytes = 0 Then Exit While
Stream.Write(buffer, 0, nReadBytes)
End While
Stream.Close()
Handled = True
End If
End Sub
You can enable or disable Flash sounds using the library. Simply set the AxCode.SoundEnabled
property:
// Disable Flash sounds
f_in_box__control1.AxCode.SoundEnabled = false;
' Disable Flash sounds
f_in_box__control1.AxCode.SoundEnabled = False
You can also adjust the sound volume. Use the AxCode.SoundVolume
property. To get the maximum volume level, use f_in_box__lib.AxCode.MaxSoundVolume
:
// Set volume to 50%
f_in_box__control1.AxCode.SoundVolume = f_in_box__lib.AxCode.MaxSoundVolume / 2;
' Set volume to 50%
f_in_box__control1.AxCode.SoundVolume = f_in_box__lib.AxCode.MaxSoundVolume \ 2
You can capture a bitmap image from the current frame of a Flash movie. This allows you to build applications that convert Flash movies into a series of images—such as bitmaps, JPEGs, and more. You can even use the captured frames to generate a video file (e.g., AVI).
To retrieve a bitmap with an alpha channel, call GetBitmap
on an instance of f_in_box__form
. The f_in_box__control
returns a bitmap without transparency.
// Save the current Flash frame as a bitmap
private void SaveFrameButton_Click(object sender, System.EventArgs e)
{
Bitmap FrameBitmap = f_in_box__control1.GetBitmap();
if (SaveBMPFileDialog.ShowDialog() == DialogResult.OK)
FrameBitmap.Save(SaveBMPFileDialog.FileName,
System.Drawing.Imaging.ImageFormat.Bmp);
}
' Save the current Flash frame as a bitmap
Private Sub SaveFrameButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles SaveFrameButton.Click
Dim FrameBitmap As Bitmap = f_in_box__control1.GetBitmap()
If SaveBMPFileDialog.ShowDialog() = DialogResult.OK Then
FrameBitmap.Save(SaveBMPFileDialog.FileName)
End If
End Sub
F-IN-BOX supports the External API, allowing two-way, synchronous communication between your application and the Flash movie—unlike fscommand
, which is asynchronous.
You can:
- Call an ActionScript function from your application
- Call an application function from your Flash script
Call an ActionScript Function from Your Application
First, register your function in ActionScript using ExternalInterface.addCallback
:
import flash.external.*;
ExternalInterface.addCallback("CallMeFromApplication", this, InternalFunction);
function InternalFunction(str: String): String {
TextArea1.text = str;
return "The function was called successfully";
}
Then call the function from your application using CallFunction
:
string response =
f_in_box__control1.FlashMethod_CallFunction(
"<invoke name=\"CallMeFromApplication\" returntype=\"xml\">" +
"<arguments><string>Some text for F-IN-BOX.NET</string></arguments>" +
"</invoke>");
MessageBox.Show("The function returned: '" + response + "'");
Dim response As String = _
f_in_box__control1.FlashMethod_CallFunction( _
"<invoke name=\"CallMeFromApplication\" returntype=\"xml\">" & _
"<arguments><string>Some text for F-IN-BOX.NET</string></arguments>" & _
"</invoke>")
MsgBox("The function returned: '" & response & "'")
Call an Application Function from a Flash Script
Use flash.external.ExternalInterface.call
in your ActionScript code:
on (click) {
_root.TextArea1.text = flash.external.ExternalInterface.call("SomeFunction");
}
Then handle the call in your application using the OnFlashCall
event:
private void f_in_box__control1_OnFlashCall(
object sender,
string request)
{
f_in_box__control1.FlashMethod_SetReturnValue(
"<string>Current time is: " +
System.DateTime.Now.ToString() +
"</string>");
}
Private Sub f_in_box__control1_OnFlashCall( _
ByVal sender As Object, _
ByVal request As String) _
Handles f_in_box__control1.OnFlashCall
f_in_box__control1.FlashMethod_SetReturnValue( _
"<string>Current time is: " & Now.ToString() & "</string>")
End Sub
You can extract semi-transparent bitmap images from a Flash movie, allowing you to create dynamic textures for your DirectX application. Here is the movie:
Here is the texture based on the movie:

One of the common challenges in programming with Macromedia / Adobe Flash Player ActiveX is managing version compatibility. For instance, the "Stacking" property exists only in Flash Player ActiveX version 5 and was removed in later versions. Attempting to access such unavailable properties or methods can cause runtime errors.
F-IN-BOX solves this by automatically detecting the version of Flash Player ActiveX in use and gracefully handling any access to non-existent features. As a result, applications built with F-IN-BOX are not only compatible with all versions of Flash Player ActiveX but are also intelligent in how they interact with the control. This significantly improves application stability and reduces the likelihood of technical support issues.