Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Throughout the rest of this chapter we're going to look at applying a reflection to a video. The first thing we'll talk about is using something called the bitmap data class. If you're following along, I'm working in 05_BitmapData.fla in the Chapter 08 folder in the Exercise Files folder. Let's take a look at how this file is set up. There are four layers: actions, video, BG, and BBg. The BG and BBg layers contain background graphics. The actions layer does not yet contain the ActionScript and the video layer contains a movie clip. If I select it on the stage, I can see it's an instance of video_mc, and if I double-click that movie clip to enter its timeline I could see that the movie clip is an instance of the FLV Playback component.
The FLV playback component is used to play progressively downloaded video. If you click the Parameters tag at the bottom of the screen and scroll down to look at the component parameters, you can see that the source video is SB_Skaters2.flv and that's in the same folder as the other Exercise Files in this chapter. So if you're following along and don't have access to the Exercise Files, you'll need to store an FLV file in the same folder as this file. Or you can just use the Video Import Wizard to import a video into the FLV playback component.
Let's click Scene 1 to return to the main timeline. You can test the movie to preview the video by pressing Command+Return on the Mac, or Ctrl+Enter on the PC. And there's a look at our video we'll be working with. So let's close the Preview window. Now we'll select the first keyframe the actions layer and open up the Actions panel by pressing Option+F9 on the Mac or F9 on the PC. The first thing we'll do to create the reflection is work with the bitmap data class. The bitmap data class creates a bitmap image out of pixels. I'll explain how it works as we start typing the code.
So create a variable called videoData with a datatype of BitmapData and we'll it set equal to a new instance of the bitmap data class. When you type open parenthesis for the bitmap data class, the code hinting in Flash tells you to pass in a width integer and a height integer and you can optionally pass in values of transparency or a fill color. What we want to do here is sort of create a copy of the video on the stage. But by using the bitmap data class, we'll create a copy out of the pixel information that's on the screen in the video, rather than creating a copy of the video itself, which could be more processor intensive.
So here for the width of our bitmap data object, I'm going to type the same width as our video. So type video_mc. That's the name of the movie clip that contains the video on the stage. .width, type a comma and a space. We'll type in video_mc.height for the height of our bitmap data object. Make sure to close out the parentheses and type a semicolon to end the statement. Then go to the next line in your code. So now we've created this new bitmap object that's as wide and as high as our video, but how do we tell Flash that this is going to be a copy of our video.
We do that by using the draw method of the bit the data class. So type videoData, captial D, dot draw. Then we need to pass in some sort of object that Flash can draw as a bitmap. And movie clip are one of those objects. So I'm going to pass in video_mc. So with the code that we've written Flash creates this bitmap data object that's the same size as our video on the stage and then gives it all the pixel information that's inside our video_mc movie clip. The next we have to do is connect all of this information held in our bitmap data object to an actual bitmap.
We'll take a look at how to do that in the next movie.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.