F-IN-BOX .NET Help

Features

Features

Load flash movies from memory directly (no temporary files!). Protect your flash movies.

It is known fact that the Flash Player ActiveX is able to load movies at certain URLs only. You have to save the movie to a temporary location from your application's resource before you can load it. You'll have to generate a corresponding link that you can pass to the Flash Player ActiveX and then delete the movie after. You'll have to admit that this is extremely inconvenient. Apart from being inconvenient there is a chance you'll fail when you try to create a temporary file if you don't have the appropriate permission or don't have access to a temporary folder. It is definitely not an appropriate approach when security is an issue since your movie can be easily intercepted. There is a solution! F-IN-BOX uses a different approach of swflash.ocx/flash.ocx code loading. It is able to load your movies directly to the Macromedia Flash Player ActiveX thereby avoiding the temporary file step. The advantages are pretty obvious. And you can also protect your movies from unauthorized access using your favourite software protection application.

Using the component you can load any flash movie from memory directly. Just use the LoadMovieFromStream and PutMovieFromStream methods. No temporary files! Load any movie on-the-fly from any supported source. For example, you can put one or more flash movies in the resource section of your application and then load it from the exe! That's the portability and power of F-IN-BOX!

Here's an example of how to load a flash movie from a resource:

[ C# ]
  1. private f_in_box__lib.f_in_box__control f_in_box__control1;  
  2. ...  
  3. f_in_box__control1.PutMovieFromStream(  
  4.   this.GetType().Assembly.  
  5.   GetManifestResourceStream("Sample1_SWF_And_FLV_Player.Embedded_Movies.movie.swf"));  

[ VB.Net ]
  1. Friend WithEvents f_in_box__control1 As f_in_box__lib.f_in_box__control  
  2. ...  
  3.   
  4. f_in_box__control1.PutMovieFromStream( _   
  5.    Me.GetType().Assembly. _  
  6.    GetManifestResourceStream("Sample1_SWF_And_FLV_Player.movie.swf"))  
Back to TopBack to Top

Create flash-enabled applications which are ready to work even when the Macromedia Flash Player ActiveX is not installed!

One of the biggest problem using the Flash Player ActiveX is the mandatory component registration. The common approach is to save swflash.ocx/flash.ocx code to temporary files and then register them. The disadvantages are the same as above mentioned - insufficient permissions to save and register an swflash.ocx/flash.ocx. Now you can forget about these problems! F-IN-BOX is able to use swflash.ocx/flash.ocx from any source. For example, you can put an swflash.ocx/flash.ocx code inside of your application's resources and instruct F-IN-BOX to use it. It is important to note that F-IN-BOX does not use temporary files and swflash.ocx/flash.ocx registration but loads and uses the code directly. No more user management rights problems - no more temporary files and no more component registrations. It is up to you to decide what swflash.ocx/flash.ocx to use - by default already registered component is used.

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# ]
  1. private f_in_box__lib.f_in_box__control f_in_box__control1;  
  2. ...  
  3.   
  4. private void MainForm_Load(object sender, System.EventArgs e)  
  5. {  
  6.     // Loads flash.ocx from resource  
  7.     System.IO.Stream StreamWithFlashOCXCode =   
  8.           System.Reflection.Assembly.GetExecutingAssembly().  
  9.              GetManifestResourceStream("Sample3_StandalonePlayer.flash_ocx.flash.ocx");  
  10.   
  11.     if (StreamWithFlashOCXCode == null)  
  12.     {  
  13.         System.Windows.Forms.MessageBox.Show("Resource 'Flash.ocx' not found");  
  14.         return;  
  15.     }  
  16.   
  17.     f_in_box__lib.AxCode code = new f_in_box__lib.AxCode(StreamWithFlashOCXCode);  
  18.   
  19.     f_in_box__control1 = new f_in_box__lib.f_in_box__control(code);  
  20.   
  21.     Controls.Add(f_in_box__control1);  
  22. }  

[ VB.Net ]
  1. Private Sub Form1_Load(ByVal sender As ObjectByVal e As System.EventArgs) _  
  2.       Handles MyBase.Load  
  3.   
  4.    'Loads flash.ocx from resource  
  5.    Dim StreamWithFlashOCXCode As System.IO.Stream = _  
  6.       Me.GetType().Assembly._  
  7.          GetManifestResourceStream("Sample3_StandalonePlayer.flash.ocx")  
  8.   
  9.    If StreamWithFlashOCXCode Is Nothing Then  
  10.       MsgBox("Resource 'Flash.ocx' not found")  
  11.    End If  
  12.   
  13.    Dim code As New f_in_box__lib.AxCode(StreamWithFlashOCXCode)  
  14.   
  15.    f_in_box__control1 = New f_in_box__lib.f_in_box__control(code)  
  16. End Sub  
Back to TopBack to Top

Transparency is fully supported

Using F-IN-BOX you are able to create applications based on transparent flash movies. You can create applications with translucency non-rectangle forms. Use Flash to make applications with modern user interface, make a business logic using .NET.

Use f_in_box__form component to work with transparency.

Please note that form transparency is supported only under Win2k (or higher), 16 / 32 bpp display mode. To check if the transparency is supported use the function IsTransparentModeAvailable:

[ C# ]
  1. // Check transparent mode  
  2. if (!f_in_box__lib.Global.IsTransparentModeAvailable)  
  3. {  
  4.    System.Windows.Forms.MessageBox.Show("Transparent mode is not available");  
  5.    return;  
  6. }  
  7.   
  8. // MyTranslucencyForm is inherited from f_in_box__lib.f_in_box__form  
  9. // Creating translucency form   
  10. MyTranslucencyForm FlashPlayerForm = new MyTranslucencyForm();  
  11.   
  12. // Loading movie from stream  
  13. System.IO.Stream MovieStream =   
  14.    System.Reflection.Assembly.GetExecutingAssembly().  
  15.       GetManifestResourceStream("Sample4_Translucency.Embedded_Movies.movie.swf");  
  16. FlashPlayerForm.PutMovieFromStream(MovieStream);  
  17.   
  18. // Positions  
  19. FlashPlayerForm.Width = 400;  
  20. FlashPlayerForm.Height = 400;  
  21. FlashPlayerForm.Left =   
  22.    System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2 -   
  23.    FlashPlayerForm.Width / 2;  
  24. FlashPlayerForm.Top =   
  25.    System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height / 2 -   
  26.    FlashPlayerForm.Height / 2;  
  27.   
  28. // Play and...  
  29. FlashPlayerForm.FlashMethod_Play();  
  30. // ...show  
  31. FlashPlayerForm.Show();  
  32.   
  33. Application.Run(FlashPlayerForm);  

[ VB.Net ]
  1. ' Check transparent mode  
  2. If Not f_in_box__lib.Global.IsTransparentModeAvailable Then  
  3.    MessageBox.Show("Transparent mode is not available", _  
  4.                    Application.ProductName)  
  5.    Return  
  6. End If  
  7.   
  8. ' MyTranslucencyForm is inherited from f_in_box__lib.f_in_box__form;  
  9. ' Creating translucency form   
  10. Dim FlashPlayerForm As New MyTranslucencyForm  
  11.   
  12. ' Loading movie from stream  
  13. Dim MovieStream As System.IO.Stream = _  
  14.    System.Reflection.Assembly.GetExecutingAssembly._  
  15.       GetManifestResourceStream("Sample4_Translucency.movie.swf")  
  16. FlashPlayerForm.PutMovieFromStream(MovieStream)  
  17.   
  18. ' Positions  
  19. FlashPlayerForm.Width = 400  
  20. FlashPlayerForm.Height = 400  
  21. FlashPlayerForm.Left = _  
  22.    Screen.PrimaryScreen.WorkingArea.Width() / 2 - _  
  23.    FlashPlayerForm.Width / 2  
  24. FlashPlayerForm.Top = _  
  25.    Screen.PrimaryScreen.WorkingArea.Height() / 2 - _  
  26.    FlashPlayerForm.Height / 2  
  27.   
  28. ' Play and...  
  29. FlashPlayerForm.FlashMethod_Play()  
  30. ' ...show  
  31. FlashPlayerForm.Show()  
  32.   
  33. Application.Run(FlashPlayerForm)  
Back to TopBack to Top

Ability to play Flash Video (FLV) from stream

Using F-IN-BOX you are able to play Flash Video (FLV) from external files, URL or directly from a stream. When F-IN-BOX loads Flash Video no temporary files are created everything runs directly from memory. You can encrypt your video and put into application's resource - F-IN-BOX loads FLV without ever saving or extracting the file to disk.

To play Flash Video from stream you should create flash movie that loads Flash Video from "private" URL (http://FLV/FlashVideo.flv). Flash Movie uses the following code to load Flash Video:

[ ActionScript ]
  1. var netConn:NetConnection = new NetConnection();  
  2.   
  3. netConn.connect(null);  
  4.   
  5. var netStream:NetStream = new NetStream(netConn);  
  6.   
  7. my_video.attachVideo(netStream);  
  8. netStream.setBufferTime(0);  
  9. netStream.play("http://FLV/FlashVideo.flv");  

When Flash tries to load Flash Video from http://FLV/FlashVideo.flv, F-IN-BOX provides content of FLV. Use the event OnLoadExternalResourceByFullPath to set handle the external resources and provide them to Flash. See the code:

[ C# ]
  1. f_in_box__control1.AxCode.OnLoadExternalResourceByFullPath +=   
  2.    new f_in_box__lib.AxCode.  
  3.       OnLoadExternalResourceByFullPathEventHandler(OnLoadExternalResourceByFullPath);  
  4. ...  
  5.   
  6. private void OnLoadExternalResourceByFullPath(  
  7.    object sender,   
  8.    String URL,   
  9.    System.IO.Stream Stream,   
  10.    ref bool Handled)  
  11. {  
  12.    if (URL == "http://FLV/FlashVideo.flv")  
  13.    {  
  14.       System.IO.Stream FLVStream =   
  15.          this.GetType().Assembly.  
  16.             GetManifestResourceStream("Sample2_SWF_FLV_Embedding.Embedded_Movies.flashvideo.flv");  
  17.   
  18.       const int size = 64 * 1024;  
  19.       byte[] buffer = new byte[size];  
  20.       int ReadBytes;  
  21.   
  22.       while ( (ReadBytes = FromStream.Read(buffer, 0, size)) > 0 )  
  23.       {  
  24.          try  
  25.          {  
  26.             Stream.Write(buffer, 0, size);  
  27.          }  
  28.          catch (System.IO.IOException e)  
  29.          {  
  30.             // Loading is interrupted  
  31.             break;  
  32.          }  
  33.       }  
  34.   
  35.       Stream.Close();  
  36.   
  37.       Handled = true;  
  38.    }  
  39. }  

[ VB.Net ]
  1. Private Sub OnLoadExternalResourceByFullPath(_  
  2.    ByVal sender As Object, _  
  3.    ByVal URL As String, _  
  4.    ByVal Stream As System.IO.Stream, _  
  5.    ByRef Handled As Boolean _  
  6. )  
  7.    If URL = "http://FLV/FlashVideo.flv" Then  
  8.       Dim FLVStream As System.IO.Stream = _  
  9.          Me.GetType().Assembly. _  
  10.             GetManifestResourceStream("Sample2_SWF_FLV_Embedding.flashvideo.flv")  
  11.   
  12.       ' You can write all content right here, but if FLVStream   
  13.       ' is BIG it takes long time  
  14.       ' The form will be unaccessible for user all this time  
  15.       ' Another option is to save Stream and write content in a   
  16.       ' separate thread  
  17.       ' You can find code example in the sample Sample1_SWF_And_FLV_Player  
  18.   
  19.       Const nSize = 64 * 1024  
  20.   
  21.       Dim buffer(nSize) As Byte  
  22.   
  23.       Dim nReadBytes As Integer  
  24.   
  25.       While (True)  
  26.             nReadBytes = FLVStream.Read(buffer, 0, nSize)  
  27.   
  28.             If 0 = nReadBytes Then Exit While  
  29.   
  30.             Try  
  31.                 ToStream.Write(buffer, 0, nReadBytes)  
  32.             Catch e As System.IO.IOException  
  33.                 ' Loading is interrupted  
  34.                 Exit While  
  35.             End Try  
  36.   
  37.       End While  
  38.   
  39.       Stream.Close()  
  40.   
  41.       Handled = True  
  42.    End If  
  43. End Sub  
Back to TopBack to Top

Enable/disable flash sounds

Using the library you can turn on/off flash sounds. Use property AxCode.SoundEnabled.

[ C# ]
  1. f_in_box__control1.AxCode.SoundEnabled = false;  

[ VB.Net ]
  1. f_in_box__control1.AxCode.SoundEnabled = False  
Back to TopBack to Top

Adjust sound volume

Using the library you can adjust sound volume. Use property AxCode.SoundVolume. To get maximum sound volume use f_in_box__lib.AxCode.MaxSoundVolume.

[ C# ]
  1. f_in_box__control1.AxCode.SoundVolume = f_in_box__lib.AxCode.MaxSoundVolume / 2;  

[ VB.Net ]
  1. f_in_box__control1.AxCode.SoundVolume = f_in_box__lib.AxCode.MaxSoundVolume \ 2  
Back to TopBack to Top

Get a snap image of the current flash movie frame

You can get a bitmap image from the current frame of a flash movie. It means you are able create applications that can coverts Flash movies to a series of bitmaps, JPEGs and others. Also you can build generated images to make an AVI video for example. f_in_box__lib.f_in_box__form.GetBitmap() returns a bitmap with alpha channel.

[ C# ]
  1. Bitmap bmpWithoutAlpha = f_in_box__control1.GetBitmap();  
  2. Bitmap bmpWithAlpha = f_in_box__form1.GetBitmap();  
  3. ...  
  4. f_in_box__control2.TransparentMode = true;  
  5. f_in_box__control2.FlashProperty_Movie = "...";  
  6. Bitmap bmpWithAlphaToo = f_in_box__control2.GetBitmap();  

[ VB.Net ]
  1. Dim bmpWithoutAlpha As Bitmap = f_in_box__control1.GetBitmap()  
  2. Dim bmpWithAlpha As Bitmap = f_in_box__form1.GetBitmap()  
  3. ...  
  4. ...  
  5. f_in_box__control2.TransparentMode = True  
  6. f_in_box__control2.FlashProperty_Movie = "..."  
  7. Dim bmpWithAlphaToo As Bitmap = f_in_box__control2.GetBitmap()  
Back to TopBack to Top

Flash External API

F-IN-BOX supports External API. You can call functions of a movie and a movie is able to get data from an application synchronously (instead of fscommand).

Call an ActionScript function from an application

Register your function using ExternalInterface.addCallback:

[ ActionScript ]
  1. import flash.external.*;   
  2.   
  3. ExternalInterface.addCallback("CallMeFromApplication"this, InternalFunction);   
  4.   
  5. function InternalFunction(str: String): String {   
  6.    TextArea1.text = str;   
  7.    return "The function was called successfully";   
  8. }  

Use method CallFunction:

[ C# ]
  1. string Response =  
  2.    f_in_box__control1.FlashMethod_CallFunction(  
  3.       "<invoke name=" + """" + "CallMeFromApplication" + """" + " returntype=" +  
  4.       """" + "xml" + """" + "><arguments><string>Some text  
  5.       for F-IN-BOX.NET</string></arguments></invoke>");  
  6.   
  7. MessageBox.Show("The function returned: '" + Response + "'");  

[ VB.Net ]
  1. Dim Response As String = _  
  2.    f_in_box__control1.FlashMethod_CallFunction(_  
  3.       "<invoke name=" + """" + "CallMeFromApplication" + """" + " returntype=" + _  
  4.       """" + "xml" + """" + "><arguments><string>Some text _  
  5.       for F-IN-BOX.NET</string></arguments></invoke>")  
  6.   
  7. MsgBox("The function returned: '" + Response + "'")  

Call an application function from a flash script

Use flash.external.ExternalInterface.call:

[ ActionScript ]
  1. on (click) {   
  2.    _root.TextArea1.text = flash.external.ExternalInterface.call("SomeFunction");   
  3. }  

Handle event OnFlashCall:

[ C# ]
  1. private void f_in_box__control1_OnFlashCall(  
  2.    object sender,   
  3.    string request)  
  4. {  
  5.    f_in_box__control1.FlashMethod_SetReturnValue(  
  6.       "Current time is: " + System.DateTime.Now.ToString() + "");  
  7. }  

[ VB.Net ]
  1. Private Sub f_in_box__control1_OnFlashCall( _   
  2.    ByVal sender As Object, _  
  3.    ByVal request As StringHandles f_in_box__control1.OnFlashCall  
  4.   
  5.    f_in_box__control1.FlashMethod_SetReturnValue(_  
  6.       "Current time is: " + System.DateTime.Now.ToString() + "")  
  7.   
  8. End Sub  
Back to TopBack to Top

Write code which is compatible with any version of Macromedia Flash Player ActiveX (3, 4, 5, 6, 7, 8, 9, 10)

One of the problem with Macromedia Flash Player ActiveX programming is that you have to control what version of Macromedia Flash Player ActiveX you are using. For example, the property "Stacking" exists only in Macromedia Flash Player ActiveX 5 but doesn't exist in later revisions. F-IN-BOX automatically detects what Macromedia Flash Player ActiveX version is being used and prevents failure if access to non existant properties/methods is attempted. Applications using F-IN-BOX are not only compatible with Macromedia Flash Player ActiveX 3, 4, 5, 6, 7, 8, 9, 10, but are also "smart" about how Macromedia Flash Player ActiveX control is used. This makes your application more robust which can result in fewer technical support issues.

Back to TopBack to Top


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