Embed video within a Flash file



When you embed video, all of the video file data is added to the Flash file. This results in a much larger Flash file and subsequent SWF file. The video is placed in the Timeline where you can see the individual video frames represented in the Timeline frames. Because each video frame is represented by a frame in the Timeline, the frame rate of the video clip and the SWF file must be set to the same rate. If you use different frame rates for the SWF file and the embedded video clip, video playback is inconsistent.
Note: To use variable frame rates, stream the video using either progressive downloading or Flash Media Server. When you import video files using either of these methods, the FLV or F4V files are self-contained and run at a frame rate separate from that of all other timeline frame rates included in the SWF file.

Embedded video works best for smaller video clips, with a playback time of less than 10 seconds. If you are using video clips with longer playback times, consider using progressively downloaded video, or streaming video using Flash Media Server.

The limitations of embedded video include:

  • You might encounter problems if the resulting SWF files become excessively large. Flash Player reserves a lot of memory when downloading and attempting to play large SWF files with embedded video, which can cause Flash Player to fail.

  • Longer video files (over 10 seconds long) often have synchronization issues between the video and audio portions of a video clip. Over time, the audio track begins playing out of sequence with the video, causing a less than desirable viewing experience.

  • To play a video embedded in a SWF file, the entire video file must be downloaded before the video starts to play. If you embed an excessively large video file, it might take a long time for the SWF file to download in its entirety and for playback to start.

  • After a video clip is imported, it cannot be edited. Instead, you must re-edit and re-import the video file.

  • When publishing your SWF file via the web, the entire video must be downloaded to the viewer’s computer before video playback can begin.

  • At runtime, the entire video must fit into the local memory of the playback computer.

  • The length of an imported video file cannot exceed 16000 frames.

  • The video frame rate and Flash Timeline frame rate must be the same. Set the frame rate of your Flash file to match the frame rate of the embedded video.

You can preview frames of an embedded video by dragging the playhead along the Timeline (scrubbing). Note that the video sound track does not play back during scrubbing. To preview the video with sound, use the Test Movie command.

Embed video within a Flash file

  1. Select File > Import > Import Video to import the video clip into the current Flash document.
  2. Select the video clip on your local computer to import.
  3. Select Embed FLV In SWF and Play In Timeline.
  4. Click Next.
  5. Choose the symbol type with which to embed the video in the SWF file.
    Embedded Video
    If you’re using the video clip for linear playback in the Timeline, importing the video into the Timeline is the most appropriate method.

    Movie Clip
    A best practice is to place video inside a movie clip instance, because you have the most control over the content. The video’s Timeline plays independently from the main Timeline. You do not have to extend your main Timeline by many frames to accommodate the video, which can make working with your FLA file difficult.

    Graphic
    When you embed a video clip as a graphic symbol, you cannot interact with the video using ActionScript (typically you use graphic symbols for static images and to create reusable pieces of animation that are tied to the main Timeline).

  6. Import the video clip directly onto the Stage (and the Timeline) or as a library item.

    By default, Flash places the video you import on the Stage. To import into the library only, deselect Place Instance on Stage.

    If you’re creating a simple video presentation with linear narration and little to no interaction, accept the default setting and import the video to the Stage. To create a more dynamic presentation, work with multiple video clips, or add dynamic transitions or other elements using ActionScript, import the video into the library. After a video clip is in the library, customize it by converting it into a MovieClip object that you can more easily control with ActionScript.

    By default, Flash expands the Timeline to accommodate the playback length of the video clip you are embedding.

  7. Click Finish.

    The Video Import wizard embeds the video into the SWF file. The video appears either on the Stage or in the library depending on the embedding options you chose.

  8. In the Property inspector (Window > Properties), give the video clip an instance name, and make any modifications to the video clip’s properties.

Import video files into the library

To import files in the FLV or F4V format, use the Import or Import To Library commands or the Import button in the Video Properties dialog box.

To create your own video player, which dynamically loads FLV or F4V files from an external source, place your video inside a movie clip symbol. When you load FLV or F4V files dynamically, adjust the dimensions of the movie clip to match the actual dimension of the video file and scale the video by scaling the movie clip.

Note: A best practice is to place video inside a movie clip instance, which gives you the most control over the content. The video’s Timeline plays independently from the main Timeline. You do not have to extend your main Timeline by many frames to accommodate the video, which can make working with your FLA file difficult.
 To import an FLV or F4V file into the library, do one of the following:
  • Select File > Import > Import To Library.

  • Select any existing video clip in the Library Panel, and select Properties from the Library Panel menu. Click Import. Locate the file to import, and click Open.

Change the properties of a video clip

You can change properties for an instance of an embedded video clip on the Stage, assign the instance an instance name, and change its width, height, and position on the Stage using the Property inspector. You can also swap an instance of a video clip—assign a different symbol to an instance of a video clip. Assigning a different symbol to an instance displays a different instance on the Stage but leaves all the other instance properties (such as dimensions and registration point) intact.

In the Video Properties dialog box, you can do the following:
  • View information about an imported video clip, including its name, path, creation date, pixel dimensions, length, and file size

  • Change the video clip name

  • Update the video clip if you modify it in an external editor

  • Import an FLV or F4V file to replace the selected clip

  • Export a video clip as an FLV or F4V file

For lessons on working with video, see the Adobe Flash Support Center at www.adobe.com/go/flash_video.

Change video instance properties in the Property inspector

  1. Select an instance of an embedded or linked video clip on the Stage.
  2. Select Window > Properties, and do any of the following:
    • Enter an instance name in the Name text field on the left side of the Property inspector.

    • Enter values for W and H to change the dimensions of the video instance.

    • Enter values for X and Y to change the position of the upper-left corner of the instance on the Stage.

    • Click Swap. Select a video clip to replace the clip currently assigned to the instance.

      Note: You can swap an embedded video clip only with another embedded video clip, and you can swap a linked video clip only with another linked video clip.

View video clip properties in the Video Properties dialog box

  1. Select a video clip in the Library Panel.
  2. Select Properties from the Library Panel menu, or click the Properties button located at the bottom of the Library Panel. The Video Properties dialog box is displayed.

Assign a new name to, update, or replace a video with an FLV or F4V file

  1. Select the video clip in the Library Panel and select Properties from the Library Panel menu.
  2. Do one of the following:
    • To assign a new name, enter the name in the Name text field.

    • To update a video, navigate to the updated video file and click Open.

    • To replace a video with an FLV or F4V file, click Import, navigate to the FLV or F4V file to replace the current clip, and click Open.

Control video playback using the Timeline

To control playback of an embedded video file, control the Timeline that contains the video. For example, to pause a video playing on the main Timeline, you would call a stop() action that targets that Timeline. Similarly, you can control a video object in a movie clip symbol by controlling the playback of that symbol’s Timeline.

You can apply the following actions to imported video objects in movie clips: goTo, play, stop, toggleHighQuality, stopAllSounds, getURL,FScommand, loadMovie, unloadMovie, ifFrameLoaded, and onMouseEvent. To apply actions to a Video object, first convert the Video object to a movie clip.

To show a live video stream from a camera, use ActionScript. First, place a Video object on the Stage, select New Video from the Library Panel menu. To attach the video stream to the Video object, use Video.attachVideo.

See also Video and attachVideo (Video.attachVideo method) in the ActionScript 2.0 Language Reference, and fl.video in the ActionScript 3.0 Language Reference.

Update an embedded video after editing its source file

  1. Select the video clip in the Library Panel.
  2. Select Properties and click Update.

    The embedded video clip is updated with the edited file. The compression settings you selected when you first imported the video are reapplied to the updated clip.