RealEyes Media
david.realeyes.com
The next major step in the video revolution is here. Flash Player 9 Update is taking a step into the high-definition (HD) video realm in a major way by adding MPEG-4 video to its already impressive ranks of video support. MPEG-4 utilizes crisp, powerful H.264 encoding and is an industry standard for video, which includes high-definition (HD) delivery. It is also the standard for HD content online and on devices such as your home television.
To pair with the excellent visual power of H.264 encoded video, Flash Player 9 Update also supports HE-AAC audio, which is the higher quality successor to MP3. Advanced Audio Coding (AAC) is a high-efficiency (HE) and high-fidelity (HiFi), low-bandwidth audio codec that can be used with or without video.
These codecs allow users to stream high-quality video at low bit rates. In addition, this update to Flash Player makes it possible to leverage tools that are standard across the industry, such as Adobe Premiere Pro, Adobe After Effects, Adobe Soundbooth, and Adobe Audition—and even such non-Adobe technology as Apple Final Cut Pro—to create and deliver compelling video content. Future updates are even being planned for Adobe Creative Suite 3 (CS3) to enhance end-to-end H.264 content development and distribution. The future is looking very bright indeed.
The new video and audio capabilities are available in Adobe Flash Player 9 Update 3 (version 9,0,115,0) and will be included in the upcoming release of Adobe AIR. Both platforms will have the ability to stream from the next generation of Flash Media Server, due to release early next year. The new Adobe Media Player, a powerful new AIR application, will also support H.264, HE-AAC, and encrypted video content using the new Flash Media Rights Management Server from Adobe.
So does this new Flash Player support for MPEG-4 and H.264 mean that it will replace the On2 VP6 codec? Absolutely not. The addition of H.264 gives developers greater choice to select the technology that best meets their needs. The current implementation of H.264 does have some limitations, such as lack of support for alpha channel and the inability to embed video into a SWF file. On2 VP6 is a solid, high-quality choice for Flash-based video projects. The On2 VP6 codec is also clear of any licensing issues that may arise with MPEG-LA. (Licensing information can be found on the MPEG LA and Via Licensing sites.) The On2 VP6 codec will remain a consistent and viable option for media delivery—see the On2 VP6 technology white paper (PDF, 140K) for more information. The added support for H.264 simply means that there are now more options and wider spread compatibility for high quality and HD video.
This article takes a look at the new codecs and file types supported in Flash Player "Moviestar." In the article I'll show you how to import both H.264 video and AAC audio into Flash, examine how to use hardware acceleration with the new Flash Player Update, and provide instructions on how to import the metadata included with MPEG-4 files.
To complete this tutorial you will need to install the following software and files:
Note: For users of Flash CS3 Professional, an update including all debug and release versions of Flash Player 9 Update 3—and a new video playback component supporting H.264—is now available via Adobe Update Manager or directly from the Flash Support Center.
Note: The archive file h264_as3_samples.zip contains sample files for creating an H.264 video player and MP4 player in Adobe Flash using ActionScript 3.0. There are both video and audio sample files, as well as FLA files for each individual walkthrough in the article. The archive file h264_as2_samples.zip provides sample ActionScript 2.0 files as an alternative to the ActionScript 3.0 walkthroughs in the article.
Although I advise that you have some general experience working with Flash and multimedia development, this article is geared towards anyone who is interested in an overview of high-definition video and audio display and techniques for optimization and playback in Flash Player 9 Update 3.
This section provides information on the H.264 video spec guidelines and AAC/AAC+ compression. You will learn what is technically supported in H.264, what standard HD video dimensions are, how H.264 is a container format—and what that means—some basic information on what AAC/AAC+ has to offer, as well as some basic encoding resources.
MPEG-4 (Motion Pictures Expert Group) H.264 is an international standard for video compression recognized by the International Organization for Standardization (ISO). H.264 is also known as "MPEG-4 Part 10" or AVC (Advanced Video Coding).
What does that mean? First, it means that when you encode your video for H.264, you're not just encoding it for Flash Player; video can be played back using other software like Apple iTunes or your iPod, or on Sony PlayStation Portable (PSP). With the new hardware scaling and multithreading support of Flash Player, you can now play back video at any resolution and bit rate, including the ultimate high-definition 1080p—as long as the system supports it (see Figure 1).

Figure 1. Screen resolutions and bit rates available with the current video standards
The MPEG-4 standard also describes a container format, which means that one file can contain several different types of data, stored as tracks. The overall file synchronizes and interleaves the data. So the video or audio in an MPEG-4 container can also be accompanied by metadata, cover art, subtitles, and other textual or visual data that can potentially be extracted by Flash Player. The container can also include multiple video and audio tracks too, but Flash Player will only play back one of each right now and ignores the rest.
Audio files encoded in an MPEG-4 container can now be used in Flash Player if they use the AAC (Advanced Audio Coding) codec. The AAC codec is a lossy compression scheme for audio that has been used since MPEG-2, but has been updated for MPEG-4. It should be familiar to most people, since all music sold from iTunes uses AAC. For you technical folks, it is much higher quality because it can support capture up to 96kHz and can support up to 48 channels and backwards prediction. AAC achieves higher audio quality than MP3 files and maintains similar or lower file sizes. AAC+ or HE-AAC (High Efficiency AAC) is the AAC codec with the addition of parametric stereo and spectral band replication that has been optimized to provide high-quality audio at a low bit rates for applications such as streaming audio. Now you can take advantage of this file format through Flash Player by bringing in MPEG-4 files with AAC encoded audio.
With the H.264 update to Flash Player, video encoding has now been standardized across the entire video ecosystem, including the Adobe Creative Suite 3 family. Tools such as Adobe Premiere and After Effects can now be used to deliver content without using additional plug-ins.
Part of adopting H.264 is leveraging the massive number of solutions on the market. The following is a list of some of the companies that provide industry standard tools for encoding video in the supported format for the new Flash Player 9 Update 3:
Flash Player 9 Update 3 plays files derived from the standard MPEG-4 container format that contain H.264 video and/or HE-AAC audio, such as F4V, MP4, M4A, MOV, MP4V, 3GP, and 3G2. One thing to note is that protected MP4 files, such as those downloaded from iTunes or digitally encrypted by FairPlay, are not supported. For a full list of codecs supported by Flash Player, read the TechNote about it.
To get more information about Flash Player 9 Update 3, visit the Flash Player product page.
To discuss Flash Player 9 Update 3 with the online developer community, visit the main Flash support forums.
One important thing about playing an H.264 video file as progressive download is that the moov atom needs to be located at the beginning of the file, or else the entire file will have to be downloaded before it begins playing. The moov atom is a part of the file that holds index information for the whole file. Unfortunately, tools such as Adobe Premiere and After Effects place this information at the end of the file, but Adobe is working to fix this in a future update to the CS3 video production tools. This isn't an issue for streaming the H.264 video files, however, so Flash Media Server users can breathe easy.
Two open-source solutions to adjusting the moov atom to allow progressive streaming are:
This section gives a hands-on approach to integrating H.264 video and AAC/AAC+ audio using the power of ActionScript. For these examples you will use an AAC/AAC+ encoded M4A file. You will gain an understanding of how to play
audio and video content using the power of the NetConnection, NetStream,
and Video classes.
MPEG-4
content must be brought in through a NetStream object, but what it takes to play H.264 content in your Flash movie
doesn't change much—although you'll
need to watch out for a few more unsupported content messages. The new status messages are NetStream.Play.FileStructureInvalid and NetStream.Play.NoSupportedTrackFound. The former is
sent when the MPEG-4 file structure is invalid, and the latter is sent when
none of the audio or video tracks in the MPEG-4 file is supported.
You can also trick the video components in Flash into playing H.264 video files by changing their file extension to .flv. The video components currently look for the .flv extension for files they are playing, although Adobe is currently working on changing the specification and in a future update this won't be necessary.
Here is the more orthodox way to play a video using progressive download:
In the Timeline, rename Layer 1 as ~AS:Main (see Figure 2).

Figure 2. Creating a new ActionScript 3.0 file
Declare a video variable at the top of the code:
var video:Video;
Create a new NetConnection object and pass in null as the only parameter for the connect method:
var connect_nc:NetConnection = new NetConnection(); connect_nc.connect(null);
Create a new NetStream object, passing your NetConnection object as a parameter to the constructor:
var stream_ns:NetStream = new NetStream(connect_nc);
In ActionScript 3.0 you'll need to specify a client object
for the NetStream to handle stream events, otherwise you will receive a compile
error. You don't actually have to create the handler methods, but you must have
the client object. Let's set the client object equal to this so the Timeline
can handle the NetStream's events. Add this code before you attach the NetStream video to the video object:
stream_ns.client = this;
Now to create the
event listeners. Create the handler function for the NetStatusEvent as shown below:
function netStatusHandler(p_evt:NetStatusEvent):void
{
}
Inside the netStatusHandler function,
create an if conditional
statement. The conditional will check if the code property of the
event object is equal to the string value of NetStream.Play.FileStructureInvalid:
if(p_evt.info.code == "NetStream.Play.FileStructureInvalid")
{
}
Inside the if conditional, use the trace() method to output a
string that states the file structure is
invalid:
trace("The MP4's file structure is invalid");
if condition,
create an else condition. The else condition will
check if the code value of the event object is equal to the string NetStream.Play.NoSupportedTrackFound:
else if(p_evt.info.code == "NetStream.Play.NoSupportedTrackFound")
{
}
Inside the else condition,
use the trace() method to output a string that
states the MP4 doesn't contain any supported tracks:
trace("The MP4 doesn't contain any supported tracks");
The completed netStatusHandler() function
should look like this:
function netStatusHandler(p_evt:NetStatusEvent):void
{
if(p_evt.info.code == "NetStream.Play.FileStructureInvalid")
{
trace("The MP4's file structure is invalid.");
}
else if(p_evt.info.code == "NetStream.Play.NoSupportedTrackFound")
{
trace("The MP4 doesn't contain any supported tracks");
}
}
Now let's attach this event handler
to the NetStream object:
stream_ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
Under the line where you added the event handler, let's create your video dynamically:
video = new Video(); addChild(video);
Use the attachNetStream method of the Video class rather
than the old attachVideo method used in ActionScript 2.0:
video.attachNetStream(stream_ns);
Pass the URL or path of your H.264
video to the play method of the NetStream object:
stream_ns.play("backcountry_bombshells_4min_HD_H264.mp4");
Playing
AAC (M4A) files is the same in both ActionScript 2.0 and ActionScript 3.0. Just
use the NetStream object and play the
file:
In the Timeline, rename Layer 1: ~AS:Main (see Figure 3).

Figure 3. Creating a new ActionScript 3.0 file: ~AS:Main
Create a new NetConnection object named connect_nc, and then call the connect() method, passing in null as the only parameter:
var connect_nc:NetConnection = new NetConnection(); connect_nc.connect(null);
Create a new NetStream object, passing your NetConnection object as a parameter to the
constructor:
var stream_ns:NetStream = new NetStream(connect_nc);
Pass the URL or path of your AAC
(M4A) file to the play method of the NetStream object:
stream_ns.play("RE-Sample.m4a");
The completed code should look like this:
var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.play("RE-Sample.m4a");
The previous section reviewed how to use ActionScript to play AAC files. Controlling your M4A audio with a Sound object is a little trickier. The Sound object can't load in M4A files the way it can load MP3 files, so for this part you'll need to bring files in using the NetStream and then work with them from there:
Declare
the SoundTransform variable at
the beginning of the code:
var mySound:SoundTransform;
You
can't directly access the properties of the NetStream's SoundTransform object, but you can reference the object
itself. So after you start playing the video in the NetStream, set the mySound variable
equal to the NetStream's soundTransform property, like this:
stream_ns.play("RE-Sample.m4a");
mySound = stream_ns.soundTransform;
Set the volume for mySound, using a number between 0 and 1:
mySound.volume = .5;
Overwrite
the NetStream's soundTransform property with mySound so the changes to the volume will be
applied:
mySound.volume = .5; stream_ns.soundTransform = mySound;
The completed ActionScript should look like this:
var mySound:SoundTransform;
var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.play("RE-Sample.m4a");
mySound = stream_ns.soundTransform;
mySound.volume = .5;
stream_ns.soundTransform = mySound;
With ActionScript 3.0, you cannot use the Sound object
to control the video's audio, because the Sound object has been altered so you can no longer attach
sounds. Instead, you'll need to use the SoundTransform object
attached to the NetStream. Here
are the steps:
Declare the SoundTransform variable at
the beginning of the code:
var mySound:SoundTransform;
This
is where things get a bit odd. You can't directly access the properties of the NetStream's SoundTransform object,
but you can reference the object itself. So after you start playing the video
in the NetStream,
set your mySound variable equal to the NetStream's soundTransform property, like
this:
mySound = stream_ns.soundTransform;
Set the volume for mySound, using a number between 0 and 1:
mySound.volume = .5;
Overwrite the NetStream's soundTransform property with mySound so
the changes to the volume will be applied:
stream_ns.soundTransform = mySound;
H.264 content is supported in Flex as well. Here are the steps:
UIComponent class. Call yours H264Video and store it in a subfolder called video. private var _video:Video; private var _connection_nc:NetConnection; private var _stream_ns:NetStream; private var _client:Object; private var _filePath:String;
super() and an init() methods:
public function H264Video()
{
super();
init();
}
init method as shown below to create Video, NetConnection, and NetStream objects:
public function init():void
{
_video = new Video();
_connection_nc = new NetConnection();
_connection_nc.connect(null);
_stream_ns = new NetStream(_connection_nc);
}
_stream_ns = NetStream(_connection_nc); line, add in a line of code to set an object as the client for your NetStream. The handling isn't necessary, but you must construct the client object:
_client = new Object(); _stream_ns.client = _client;
Also add in a
line of code to handle status events from the NetStream:
_stream_ns.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
init() method, attach the NetStream to the video, add the video to the display list, and start playing the video file if
the _filePath exists. The completed method should look like this:
public function init():void
{
_video = new Video();
_connection_nc = new NetConnection();
_connection_nc.connect(null);
_stream_ns = new NetStream(_connection_nc);
_client = new Object();
_stream_ns.client = _client;
_stream_ns.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
_video.attachNetStream(_stream_ns);
this.addChild(_video);
if(_filePath)
{
_stream_ns.play(_filePath);
}
}
Create the function to handle status events. In particular, handle those two new status events that you can track in H.264 video:
private function onStatus(p_evt:NetStatusEvent):void
{
if(p_evt.info.code == "NetStream.Play.FileStructureInvalid")
{
Alert.show("The MP4's file structure is invalid.", "Status");
}
else if(p_evt.info.code == "NetStream.Play.NoSupportedTrackFound")
{
Alert.show("The MP4 doesn't contain any supported tracks", "Status");
}
else if(p_evt.info.level == "error")
{
Alert.show("There was some sort of error with the NetStream", "Error");
}
}
Create
getter/setter methods for the _filePath property. On setting the filePath, call the play() method on the NetStream instance and pass it the filePath's value. Also
add a [Bindable] metadata tag above the
getter, like this:
[Bindable]
public function get filePath():String
{
return _filePath;
}
public function set filePath(p_path:String):void
{
_filePath = p_path;
_stream_ns.play(_filePath);
}
You can then bring
your video into the Flex application either solely by ActionScript or by using
MXML. In your MXML file, you can create a tag on the Stage for your H264Video, and then specify an id, x, y values, etc. If you are using the Adobe
AutoComplete Input Flex component to get code hints, Flex will create the
namespace for you to use this tag. Also, set the filePath property on the MXML tag, pointing to your video file:
<video:H264Video id="video_h264" x="10" y="10" filePath="myVideo.mov" />
In the past, when you worked with Flash-based video, you could inject
additional data into the video file for use during playback. The onMetaData event was
commonly used to retrieve this data during runtime. The data would contain
simple pertinent information such as track length and video dimensions. That
same type of information is also available with the new supported video
formats.
Since MPEG is a container format that can contain many different items
of information grouped together into one file, it is useful to access different
bits of information inside that container. Using the onMetaData event of the NetStream, you can extract a variety of information
such as dimensions, length, codec, seek points, and potentially cover art,
subtitles, audio book chapters, and other text and images from both H.264 and
M4A files.
It's important to note that if the seek points aren't included in the metadata,
you won't be able to seek in the file at all. There are also new onImageData and onTextData events that
respond to this data for both audio and video files. The onImageData returns GIF,
PNG, or JPEG data as a ByteArray in ActionScript 3.0
only. The onTextData can return text data such as subtitles. Cover
art may also be encoded in your audio or video files; they are most often
accessed through the onMetaData event. I will explore this in the following
walkthrough.
Here are the steps for extracting metadata from video files:
Create a new layer in the Timeline under the ~AS:Main layer and name it output (see Figure 4).

Figure 4. Creating a new layer beneath: output
x property of the text field to 5.y property of the text field to 5. width property of
the text field to 175.height property of
the text field to 300.In ActionScript
3.0, you have to handle the onMetaData event through the client object of the NetStream. So first
write the function that handles the metadata and have it receive the event
object as its only parameter. Write this code below the netStatusHandler function:
function onMetaData(p_info:Object):void
{
}
Inside
the onMetaData event handler, create a for loop that will loop through and display the properties of the p_info object to the dynamic text field. The code should look similar to this:
for(var propName:String in p_info)
{
output_txt.appendText(propName + "=" + p_info[propName] + "\n");
}
Use
the metadata to set the size of the video object. After the for loop in the onMetaData event
handler, set the width property of the video object to the value of p_info.width, like this:
video.width = p_info.width;
Set the height property of the video object to the value
of p_info.height:
video.height = p_info.height;
Note: The video file in the sample files is 1280 x 720, so you'll want to size your Flash project to accommodate that size. Use 1465 x 720 as the width and height dimensions to size your sample files.
The completed onMetaData handler should now look like this:
function onMetaData(p_info:Object):void
{
for(var propName:String in p_info)
{
output_txt.appendText(propName + " = " + p_info[propName] + "\n");
}
video.width = p_info.width;
video.height = p_info.height;
}
Test
your movie in the browser. You may not see your output text field because the
video is getting loaded on top of it. To solve that problem, you'll move the
video over. Right before the addChild(video); line, set the x value of the video
to 185 and the y value of the video to 5:
video.x = 185; video.y = 5;
Video object should resize to match the size of the source
video.Here are the steps for extracting metadata from audio files:
Create a new layer in the Timeline under the existing ~AS:Main layer and name it output (see Figure 5).

Figure 5. Creating a new layer: output
Select
the text field with the instance name length_txt and set its x position to 10 and its y position to 5. Set the width of the text field to 240 and its height to 21. Also click the Show Border Around Text
button in the Property inspector to add a border around the text
field. Your Property
inspector should look similar to Figure 6.

Figure 6. Updating the text field settings
Select
the text field with the instance name copy_txt TextField and set its x position to 10 and its y position to 31. Also set its width to 240 and its height to 21 and click the Show
Border Around Text button in the Property inspector. After making these
changes, the Stage should now roughly appear like the example in Figure 7.

Figure 7. Updating the settings of the two text fields
After declaring the NetStream object, set
the client property of
the NetStream object equal
to the reference value this, so
that the root Timeline will handle events from the NetStream. In ActionScript
3.0, you have to handle the onMetaData event through the client object of the NetStream:
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.client = this;
Create
an event handler for the onMetaData event. The function should receive one
parameter named p_info that is typed as an Object:
function onMetaData(p_info:Object):void
{
}
Inside
the onMetaData event
handler, set the text property of the length_txt text field to
display the length of the audio source file. The length of the audio is stored
as seconds in the duration property of the event object, so you can
multiply that number by 1000 to get the duration of the media in milliseconds:
length_txt.text = "Length: " + (p_info.duration*1000) + " ms";
Set the text of the copy_txt TextField to display the codec used to encode the
audio source file. This codec information is stored in the audiocodecid property of the p_info object received by the onMetaData event handler:
copy_txt.text = "Codec: " + p_info.audiocodecid;
The completed code should look like this:
var mySound:SoundTransform;
var connect_nc:NetConnection = new NetConnection();
connect_nc.connect(null);
var stream_ns:NetStream = new NetStream(connect_nc);
stream_ns.client = this;
function onMetaData(p_info:Object):void
{
length_txt.text = "Length: " + (p_info.duration*1000) + " ms";
copy_txt.text = "Codec: " + p_info.audiocodecid;
}
stream_ns.play("RE-Sample.m4a");
mySound = stream_ns.soundTransform;
mySound.volume = .5;
stream_ns.soundTransform = mySound;
Write
a function that will display a cover image. The cover image data is received in
the onMetaData event handler
as an array of ByteArrays. Under the onMetaData event handler, create a function named handleCoverImage and have it
accept an Array named p_data as its only parameter:
function handleCoverImage(p_data:Array):void
{
}
Note: The cover data you'll be bringing in is 320 x 240, so you should resize your Flash movie to match those dimensions.
Inside
the handleCoverImage() function,
create a new Loader variable and set it equal to a new Loader:
var loader:Loader = new Loader();
After creating the
new Loader, call its loadBytes method to
load in the data at the first index of the array, casting that value as a ByteArray. You can also retrieve this information for
video, as well as audio, if it has the cover art metadata attached:
loader.loadBytes(p_data[0] as ByteArray);
In the last line of
the function, you'll need to add the Loader to the display list
at index 0 so that the image you load will be visible. Do this by calling the addChildAt() method and
passing it loader as the first parameter and 0 as the second
parameter:
addChildAt(loader, 0);
The completed handleCoverImage() function
should look like this:
function handleCoverImage(p_data:Array):void
{
var loader:Loader = new Loader();
loader.loadBytes(p_data[0] as ByteArray);
addChildAt(loader, 0);
}
Above the existing
code in the onMetaData event handler, create an if conditional
statement. The if condition should check if the cover data, stored as covr, in the tags object exists:
if(p_info.tags.covr)
{
}
length_txt.text = "Length: " + (p_info.duration*1000) + "ms";
copy_txt.text = "Codec: " + p_info.audiocodecid;
Move the code where
you set the text property for the length_txt TextField above the if condition,
like this:
length_txt.text = "Length: " + (p_info.duration*1000) + " ms";
if(p_info.tags.covr)
{
}
Wrap the code where
you set the text properties for copy_txt in an else statement:
if(p_info.tags.covr)
{
}
else {
copy_txt.text = "Codec: " +
p_info.audiocodecid;
}
Inside the if condition,
set the htmlText property of the length_txt TextField to display the
copyright information for the audio as a hyperlink to the URL associated with
the media. This information is stored as the ©cpy and ©url attributes of
your sample media files:
if(p_info.tags.covr)
{
copy_txt.htmlText = "© <a href='"+ p_info.tags["©url"] + "'>"
+ p_info.tags["©cpy"] + "</a>";
}
Declare
a covr variable and
set it equal to the covr metadata and cast this value as an Array. Theoretically, you can have multiple images
associated with the media as cover data, so the covr property should be
treated as an Array:
var covr = p_info.tags.covr as Array;
Pass the covr variable as a
parameter to the handleCoverImage function you wrote earlier:
handleCoverImage(covr);
The completed onMetaData handler should look like this:
function onMetaData(p_info:Object):void
{
length_txt.text = "Length: " + (p_info.duration*1000) + "ms";
if(p_info.tags.covr)
{
copy_txt.htmlText = "© <a href='"+ p_info.tags["©url"] + "'>" + p_info.tags["©cpy"] + "</a>";
var covr = p_info.tags.covr as Array;
handleCoverImage(covr);
}
else
{
copy_txt.text = "Codec " + p_info.audiocodecid;
}
}
Test the movie in the browser. You should now see the cover art included with the audio duration and the copyright information about the media (see Figure 8).

Figure 8. Audio source file metadata displayed when the movie is tested in a browser
Another very exciting new feature in Flash Player 9 Update 3 is hardware scaling support for Flash Player—which lends itself perfectly to enhancing the video playback experience of HD video in full screen—especially when you consider the size of HD 1080p video (1920 x 1080). The new hardware acceleration was not built solely for the new H.264 video capabilities. It also helps with larger On2 VP6 video files and the display of SWF content in general.
Right-click (Windows) or Control-click (Mac) inside the Flash Player content in your browser window to display the Flash Player context menu and choose the Settings option to access the Adobe Flash Player Settings panel. The first tab shown is the Display tab (see Figure 9).

Figure 9. Display tab of the Flash Player Settings panel for toggling hardware acceleration on and off
The only item on the Display tab is a checkbox asking whether or not you'd like to enable hardware acceleration. If the box isn't already checked, check it to enable hardware acceleration—which will be in use if the content triggers it using the new ActionScript API. Unchecking or disabling this option forces software acceleration for the case when the scaling API is used. If hardware acceleration is enabled and the API is used, then Flash Player uses the hardware. The key area where you'll see hardware acceleration in effect is in full-screen mode, whether you're scaling a portion of the movie to full screen or the entire movie.
Now let's put the new hardware acceleration to use by scaling just a portion of your SWF to full screen. For overall advice on the particulars of making your movie go full screen, see Tracy Stampfli's excellent article, Exploring full-screen mode in Flash Player 9. If you would like to see an example of the visual effectiveness of full-screen video, check out this Adobe Labs demo.
Here are the steps to scale a portion of the movie to full-screen video:
Rectangle and Stage classes at
the beginning of your ActionScript:
import flash.geom.*; import flash.display.Stage;
Any attempts to
make the Stage go full screen have to be in response to a user interaction,
such as an onRelease or onKeyDown event. Right now, however,
you can write the function to make the movie go full screen. Your goFullScreen() function will
take an event object as its sole parameter:
function goFullScreen(p_evt:Object):void
{
}
Inside the
function, create a Rectangle that has the same dimensions as the video
and place it at the same x and y coordinates:
var scalingRect:Rectangle = new Rectangle(video.x, video.y, video.width, video.height);
Set the fullScreenSourceRect property of
the Stage to the Rectangle you just made. Because that property is not
yet officially in the class, you must use square bracket notation to do this:
stage["fullScreenSourceRect"] = scalingRect;
After that line of
code, create an if conditional statement that checks to see if the display
state of the Stage is normal or not, by checking it against the Stage class's NORMAL property,
like this:
if(stage.displayState == StageDisplayState.NORMAL)
{
}
Inside the
conditional statement, change the display state of the Stage to full screen
using the FULL_SCREEN property:
stage.displayState = StageDisplayState.FULL_SCREEN;
else statement that sets the display state of the Stage to
normal again:
else
{
stage.displayState = StageDisplayState.NORMAL;
}
The completed goFullScreen() function looks like this:
function goFullScreen(p_evt:Object):void
{
var scalingRect:Rectangle = new Rectangle(video.x,
video.y, video.width, video.height);
stage["fullScreenSourceRect"] = scalingRect;
if(stage.displayState == StageDisplayState.NORMAL)
{
stage.displayState = StageDisplayState.FULL_SCREEN;
}
else
{
stage.displayState = StageDisplayState.NORMAL;
}
}
Return to the Timeline and create a new layer above the output layer. Name the new layer control (see Figure 10).

Figure 10. Naming the new layer control after creating a new layer above the output layer
While Frame 1 of the control layer is selected, draw a roughly 30 x 30 rectangle on the Stage. Select the rectangle and invoke the Convert to Symbol dialog box (press F8). Select the type of movie clip to have the rectangle act as a full-screen button. Name the new symbol Button click OK (see Figure 11).

Figure 11. Converting the rectangle to a movie clip symbol named Button
The fullScreen_mc button will have to
use the addEventListener method to call the goFullScreen() function. Add this
line after the goFullScreen() function:
fullScreen_mc.addEventListener("click", goFullScreen);
Select File > Publish Settings to access the Publish Settings dialog box. Select the HTML tab. In the Template drop-down menu, select Flash Only – Allow Full Screen (see Figure 12) and click OK.

Figure 12. Selecting the option Flash Only – Allow Full Screen
fullScreen_mc button. You should see your video go to full-screen
display mode.To learn more about working with video in Flash Player 9 Update 3, go visit Tinic Uro's blog. To get more details about the high-definition standards and codecs, see the Wikipedia articles on H.264 and AAC.
The addition of H.264 and AAC support in Flash Player 9 Update 3 allows you to easily use high-definition, industry standard video and audio. With this update, Flash Player raises the bar further for video on the web and offers display possibilities across a wide range of devices. Pairing the new video capabilities of Flash Player and future updates to the Adobe Creative Suite workflow—in addition to new products like Adobe AIR and Adobe Media Player—it is safe to say that very exciting times are ahead.
David Hassoun is the founder of RealEyes Media, LLC, a digital media firm based in Colorado that focuses on interactive motion media and advanced Flash and Flex platform applications. David has always had a passion for motion media, the power of video, and the challenges of usability and interactivity. David is an Adobe Certified Master Instructor, teaches advanced RIA classes at the University of Denver, serves as the Rocky Mountain Adobe User Group Manager, and has taught and developed advanced Flash and Flex application courses. As a consultant or while employed with other firms, he has worked for a wide range of companies such as American Express, Chase Manhattan, Qwest, Boeing, Macromedia, Adobe, US Air Force, Bechtel/Bettis, and many more. David regularly performs advanced code and technical best practices reviews, and has provided directional advice for international industry leaders over the past years—including many technical, courseware, and application reviews as an industry expert.