Embed Nimbb in an Adobe Flash Professional application

You can easily embed the Nimbb Player into an Adobe Flash Professional application. This gives you an easy way to record and playback videos into your Flash applications. In this example, we explain how to build a demo Flash application that embeds Nimbb to record a video using your webcam. We use Adobe Flash Professional CS6, but this example should work on prior versions that are compatible with ActionScript 3 projects.

This example requires you to specify your developer key (see tutorial).


Nimbb Player embedded into an Adobe Flash Professional application:

Build the application

Open Adobe Flash Professional and follow these steps:

  • Create a new Flash document of type "ActionScript 3.0";
  • Add a Button component to the scene and in the properties, set instance name to "btnRecord" and change label to "Record";
  • Add a Label component to the scene and set Instance Name to "lblGuid" and change text to "guid:";
  • Open the Actions window to display the code editor (or press F9 key);
  • Make sure to select Scene 1 on the left side of the code editor;
  • Copy and paste the ActionScript 3 code (provided below) into the code editor;
  • In the code, replace "XXXXXXXXXX" by your Nimbb public developer key;
  • Save the project under name "demo.fla".

ActionScript3 code

// Global variables.
var _Mask:Shape;
var _Nimbb:Object;
var _Loader:Loader;
var _SM:Object;

// Set security.

// Add button event.
btnRecord.addEventListener(MouseEvent.CLICK, btnRecord_clicked);

// Define a mask for the loader. This is used to set the position and size of the Nimbb Player.
_Mask = new Shape();
_Mask.graphics.drawRect(0, 0, 320, 240);

// Start loading the Nimbb Player.
_Loader = new Loader(); 
_Loader.mask = _Mask;
_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, Loader_completed);
_Loader.load(new URLRequest("https://player.nimbb.com/nimbb.swf?mode=record&key=XXXXXXXXXX&simplepage=1&lang=en"));

// Loading of the Nimbb Player completed.
function Loader_completed(event:Event):void
  // Add Nimbb Player to the stage.

  // Define Nimbb events to listen to.  Add more based on your needs.
  _Loader.addEventListener("Nimbb_initCompleted", Nimbb_initCompleted);
  _Loader.addEventListener("Nimbb_videoSaved", Nimbb_videoSaved);

// Event: Nimbb Player has been initialized and is ready.
function Nimbb_initCompleted(event:Event):void
  // Get reference to the Nimbb Player.
  _SM = _Loader.content;
  _Nimbb = _SM.getChildAt(0);
  // Set size so that the player gets the correct dimension.
  _Nimbb.resize(320, 240);

// Start recording a video.
function btnRecord_clicked(event:MouseEvent):void

// Event: the video was saved.
function Nimbb_videoSaved(event:Event):void
  lblGuid.text = "guid:" + _Nimbb.getGuid();

Testing your application

As your application is loading the Nimbb Player using the Loader class, it is not possible to test your application using the Debug Movie feature of the Adobe Flash Professional software. If you try, you will get a Security Sandbox Violation error with text similar to "Untrusted local SWFs may not contact the Internet. SecurityError: Error #2028". The reason is that you need to run your application from a website (URL starting with "http://") and not from a local file system. Thankfully, you can easily test by simply copying the application to your web server's folder. Follow these steps to test the demo Flash application:

  • In Adobe Flash Professional, in the File menu, click Publish;
  • Using a file explorer, browse to the folder where you saved your project and locate the files demo.html and demo.swf;
  • Copy the two files onto a folder on your web server;
  • Open the demo.html file in your browser.

When testing the application, you see that you can start recording a video by clicking the Record button (note that you can also click the Record button inside the player). Once you click the Save button in the player, the lblGuid label is updated to display the GUID of the recorded video. This example demonstrates how to communicate between your Flash application and the Nimbb Player.

View more tutorials.

SIGN UP NOW 7-day free trial

Check out our Developer guide to get started with Nimbb.