User Guide
522 FLVPlayback Component (Flash Professional Only)
The following ActionScript code loads the contentPath property to play an FLV file in the
default video player and adds a cue point for it. When the
ready event occurs, the event
handler opens a second video player by setting the
activeVideoPlayerIndex property to the
number 1. It specifies an FLV file and a cue point for the second video player and then makes
the default player (0) the active video player again.
/**
Requires:
- FLVPlayback component on the Stage with an instance name of my_FLVPlybk
*/
// add a cue point to the default player
import mx.video.*;
my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/
clouds.flv";
my_FLVPlybk.addASCuePoint(3, "1st_switch");
var listenerObject:Object = new Object();
listenerObject.ready = function(eventObject:Object):Void {
// add a second video player and create a cue point for it
my_FLVPlybk.activeVideoPlayerIndex = 1;
my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/
water.flv";
my_FLVPlybk.addASCuePoint(3, "2nd_switch");
my_FLVPlybk.activeVideoPlayerIndex = 0;
};
my_FLVPlybk.addEventListener("ready", listenerObject);
To switch to another FLV file while one is playing, you must obtain control to make the
switch in your ActionScript code. Cue points allow you to intervene at specific points in the
FLV file using a
cuePoint event. The following code creates a listener for the cuePoint event
and calls a handler function that pauses the active video player (0), switches to the second
player (1), and plays its FLV file:
// create a listener object
var listenerObject:Object = new Object();
// add a handler function for the cuePoint event
listenerObject.cuePoint = function(eventObject:Object):Void {
// display the no. of the video player causing the event
trace("Hit cuePoint event for player: " + eventObject.vp);
// test for the video player and switch FLVs accordingly
if (eventObject.vp == 0) {
my_FLVPlybk.pause(); //pause the first FLV
my_FLVPlybk.activeVideoPlayerIndex = 1; // make the 2nd player active
my_FLVPlybk.visibleVideoPlayerIndex = 1; // make the 2nd player
visible
my_FLVPlybk.play(); // begin playing the new player/FLV
} else if (eventObject.vp == 1) {
my_FLVPlybk.pause(); // pause the 2nd FLV
my_FLVPlybk.activeVideoPlayerIndex = 0; // make the 1st player active