FLASH VIDEO PLAYERS -- COMPONENT BASED

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

FLVPlayback components along the timeline

 

You can add several FLVPlayback components along the timeline and "jump" to them using frame labels.

  1. Add FLV videos to project folder (i.e., Lion.flv, Tiger.flv, etc.)
  2. Create a new movie and layout your Flash video.
  3. Add buttons for each video with instance names (i.e., video_btn1, video_btns2, etc.)
  4. Add Frame labels to jump to for each video that needs to be played.
  5. Create a new layer (i.e., Videos) and add a FLVPlayer component beneath each corresponding frame labels. Set each to AutoPlay in the Properties Panel.
  6. Create a new layer (i.e., ActionScript) and move to top and add the following code to the first frame of the timeline.
stop()
video_btn1.addEventListener(MouseEvent.MOUSE_DOWN,onVideoPlay1);
function onVideoPlay1(eventObject:MouseEvent):void {
	gotoAndStop("penguins");
}

video_btn2.addEventListener(MouseEvent.MOUSE_DOWN,onVideoPlay2);
function onVideoPlay2(eventObject:MouseEvent):void {
	gotoAndStop("mandrill");
}

video_btn3.addEventListener(MouseEvent.MOUSE_DOWN,onVideoPlay3);
function onVideoPlay3(eventObject:MouseEvent):void {
	gotoAndStop("tiger");
}

video_btn4.addEventListener(MouseEvent.MOUSE_DOWN,onVideoPlay4);
function onVideoPlay4(eventObject:MouseEvent):void {
	gotoAndStop("lion");
}

 

A single FLVPlayback component with a single frame

Adding several FLVPlayback components along the timeline makes for more coding. To simplify the code, follow the steps below:

  1. Delete all but the first frame
  2. Select the FLVPlayback component and deselect the AutoPlay option.
  3. Delete any blank layers
  4. Change the instance names of the button to match the flv files minus the  ".flv" extension.
  5. Replace the code with the following code:
stage.addEventListener (MouseEvent.MOUSE_DOWN,onVideoPlay);
function onVideoPlay (eventObject:MouseEvent):void
{
	trace(eventObject.target.name + ".flv")
	video_player.source = eventObject.target.name + ".flv";
	video_player.play();
}