User Guide
576 FLVPlayback Component (Flash Professional Only)
Example
The following example creates two video players to play two FLV files consecutively in a single
FLVPlayback instance. When the second FLV file finishes, the event handler for the
complete event calls the closeVideoPlayer() method to close the second player. If you
click the Play button to play the FLV files a second time, you see that the video player for the
second player is gone, which causes the component to throw an error (VideoError) and show
a message that says the FLVPlayback instance cannot find the FLV file.
Drag an FLVPlayback component to the Stage, and give it an instance name of
my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of
the Timeline:
/**
Requires:
- FLVPlayback component on the Stage with an instance name of my_FLVPlybk
*/
// specify name and location of FLV for default player
import mx.video.*;
my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/
clouds.flv";
var listenerObject:Object = new Object();
listenerObject.ready = function(eventObject:Object):Void {
// add a second video player and specify the name and loc of its FLV
my_FLVPlybk.activeVideoPlayerIndex = 1;
my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/
water.flv";
// reset to default video player, which plays its FLV automatically
my_FLVPlybk.activeVideoPlayerIndex = 0;
};
my_FLVPlybk.addEventListener("ready", listenerObject);
listenerObject.complete = function(eventObject:Object):Void {
// if complete is for 2nd FLV, make default active and visible
if (eventObject.vp == 1) {
my_FLVPlybk.activeVideoPlayerIndex = 0;
my_FLVPlybk.visibleVideoPlayerIndex = 0;
my_FLVPlybk.closeVideoPlayer(1);// close 2nd video player
} else { // make 2nd player active & visible and play FLV
my_FLVPlybk.activeVideoPlayerIndex = 1;
my_FLVPlybk.visibleVideoPlayerIndex = 1;
my_FLVPlybk.play();
}
};
// add listener for complete event
my_FLVPlybk.addEventListener("complete", listenerObject);
See also
FLVPlayback.close, FLVPlayback.activeVideoPlayerIndex,
FLVPlayback.visibleVideoPlayerIndex