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!

Video Freeze-frame

Video Freeze-frame

In Flash Player 8, you can use the new BitmapData class to create bitmaps at runtime with ActionScript. This class holds individual pixel data and numerous methods are available to modify the pixel data inside of a BitmapData object.

One such method can be used to take a snapshot of a movie clip’s current state as a bitmap object. You can also take a snapshot of the current state of a Video object, which is good news for me, because this experiment needs to access the individual pixels of the video captured from the webcam. To take a snapshot of the current state of a Video object or movie clip at runtime using ActionScript, use the draw() method of the BitmapData class.

//(From previous page)
/* capture the video stream from the active webcam and display
it inside the video object */

import flash.display.BitmapData
import flash.geom.Matrix

create a new bitmap object that is the same size
as the Video object to store the pixel data

var snapshot:BitmapData=new BitmapData(output_vid._width,output_vid._height);

create a function that takes a snapshot
of the Video object whenever it is called

function takeSnapshot()
//draw the current state of the Video object into
//the bitmap object with no transformations applied
snapshot.draw(output_vid,new Matrix());

You can then display a BitmapData object inside of a movie clip using the new attachBitmap() method:

//create a movie clip to hold the bitmap when we attach it

//display the specified bitmap object inside the movie clip

You can then call your snapshot function, for example, when a button is pressed to display a freeze frame of the video object:


Note: Ensure that you do not have the video object at the upper left corner of the Stage, or the bitmap_mc instance will overlap your video.