Foundation Flash 8 Video
by Tom Green and Jordan Chilcott

Excerpted from “Foundation Flash 8 Video” by Tom Green and Jordan Chilcott
© 2006. Used with the permission of friends of ED, a division of Apress. To purchase this book, please visit www.friendsofed.com.
by Tom Green and Jordan Chilcott
As you learned in “Frame video with a mask”, a simple mask is a great way to frame your video in Flash® 8. Once you master that technique, it’s time to advance your game, and create a more complex image mask.
In our example, one of the authors has a phone sitting on his desk that contains an Information screen. He has wistfully looked at the phone on several occasions and wondered, “What would this look like if it were a video screen?” The great thing about Flash is it can be used to play these what-if games and turn a phone’s information display into a video display.
To follow along with this tutorial, download the ComplxMsk_Files.zip file.
Before we start, now would be a good time for you to discover a “gotcha” that is a part of the FLVPlayback component: The component really hates it when you distort the component using the Free Transform tool. It especially dislikes it when you skew the component. The implication of this is you will be doing a lot of unnecessary fiddling and tweaking to get a video to fit into an oddly shaped area (see Figure 1).
Figure 1: The FLVPlayback component is not exactly “distortion-friendly.”
The solution is to use a video object from the library instead of the component. Let’s put a video in a phone, shall we? To get started, create a new folder named Phone and place a copy of the BMX.flv file that you downloaded into your new folder.
Figure 2: It starts with a phone.
You won’t get an exact fit because the component and the video objects are not vector-based. The sides of the object, when manipulated by the Free Transform tool, can’t be changed independently of each other. They all change. Moving the center point to a handle only freezes that side in place, and the other three edges will move in relation to the center point.
There are two solutions to this issue. The first is to draw a shape in Flash that matches the shape of the cutout and to use that shape to mask the video. On the surface, this sounds like a great solution, but is actually duplicating effort because that will also be the purpose of the hole in the phone. The other is to change the shape of the video object to approximate the shape of the cutout.
Figure 3: Use the geometry of the mask area to determine the shape of the video object.
var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); myVideo.attachVideo(ns); ns.play (“BMX.flv”);
If you test the piece right now, you won’t see anything because the video is under the screen. To fix that, select the screen, and reduce its Alpha value to about 45–50 percent. Now test the movie (see Figure 4).
Figure 4: The video phone.
Even though the video is somewhat distorted, it still looks fine in the viewer. However, the end result is, in many respects, an optical illusion. The user’s eyes will match the video to the geometry of the hole. If you go to the Vodafone Future Vision site, you will see this illusion used quite deliberately. For example, in the Entertainment section, Lisa has a “Visual Bracelet,” which she uses to keep in touch with her friends. If you select Experience, you will watch Lisa get invited out that evening by a couple of her friends. The video plays under the bracelet, and the curve of the bracelet also gives the illusion of the video being curved to follow that geometry.
There is obviously a small problem with your video. The words on the screen still show through. You can fix this by carefully using the clone tool in either Adobe Photoshop® or Fireworks® to paint over the word with blank areas of the screen. Another neat trick is to simply create a new movie clip and draw a square in the clip using the Rectangle Tool in the toolbox, sample a green pixel in the screen, and fill the square with that color. Then all you need to do is to slide the Screen layer under the Phone layer and place the movie clip there. Resize it to fit the hole and apply about 50–60 percent opacity. If you want to try it, replace the Screen1 movie clip with the ScreenVid movie clip in the library.