Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Webcam Motion Detection: Using the BitmapData API in Flash 8

Webcam Motion Detection: Using the BitmapData API in Flash 8

Some time ago I came across various processing experiments that monitored the active webcam for movement and allowed the user to interact with the program or art piece by moving around when in view. Until now Macromedia Flash Player has never been able to access the pixel data of a webcam feed; however, with the release of Macromedia Flash Player 8 comes an impressive and generous new feature—similar in many respects to Imaging Lingo in Director—that gives developers the power to create and modify bitmaps at runtime with ActionScript. This feature comes in the form of a new BitmapData ActionScript API.

One of my first experiments with Flash Player 8 was to try and re-create this webcam motion detection in an optimized fashion so that I could use this input as the basis for other webcam experiments, such as moving a ball around the screen by moving my hand around in view of the webcam.

Note: To view the example below, you need to have a webcam installed.

To view this content, you need the latest version of the Macromedia Flash Player.
Download the free Macromedia Flash Player now.

I set out on my journey into the realms of pixeldom and achieved the desired result. In this article, I discuss my journey and the outcome. By the end of this article, I will have taught you a little about how to use some of the new features available in the latest release of Flash Player and you should be able to use this knowledge to write some of your own experiments with webcams.


To complete this tutorial you will need to install the following software and files:

Macromedia Flash 8 Professional

Webcam Installed

If you have more than one camera installed on your machine you will need to select the camera that Flash Player should use. You can do this using the Flash Player Settings dialog box:

  1. Right-click the Flash file.
  2. Choose Settings.
  3. Click the Camera tab (the fourth and last tab).
  4. Choose the desired camera from the dropdown list.
  5. Click Close.
  6. Refresh the page to restart the Flash file.

It is best to only allow camera access to trusted websites.

Tutorials and sample files:

Prerequisite Knowledge

An understanding of hexadecimal colors and ActionScript 1.0 and 2.0.