Start the Flash program. Click "New" from the File menu on the main Flash menu bar. Click the file type "Flash File(ActionScript 3.0)" from the New Document dialog box that appears. Click "OK" to close the dialog box.
Click the "Components" option from the Window menu. Click and the drag the FLVPlayer component from the component library to the Flash stage so that the flash video class will load when the program starts. Press the "Delete" key on your keyboard to delete the FLVPlayback component.
Select the "Actions" option from the Window menu on the main Flash menu bar to open the Actions editor. Position your mouse cursor on the first line of the Actions editor. Click your mouse button, and type in the code below to import the Flash video classes needed for the FLVPlayback component to work in the Flash environment.
import fl.video.*;
Type the code below, starting at the next line in the Actions editor, to create an instance of the FLVPlayback component and place it on the stage at the stage coordinates (25,50).
var my_FLVPlybk = new FLVPlayback();
my_FLVPlybk.x = 25;
my_FLVPlybk.y = 50;
Type the code below, starting at the next line in the Actions editor, to select the water.flv video file from the example.com website to play in the FLVPlayback component and place the component on the stage when the Flash movie plays.
my_FLVPlybk.source = "http://www.helpexamples.com/flash/video/water.flv";
addChild(my_FLVPlybk);
Type the code below, starting at the next line in the Actions editor, to create and place an instance of a MovieClip object that is drawn with a pixel line width of 4 pixels, is filled with the color red, is the shape of a rectangle (positioned at stage coordinates [350,200] with a width of 50 pixels and a height of 20 pixels), and will call a function that will stop the video when the MovieClip object(myButton) is clicked with the mouse.
var myButton:MovieClip = new MovieClip();
myButton.graphics.lineStyle(4);
myButton.graphics.beginFill(0xFF0000);
myButton.graphics.drawRect(350, 200, 50, 20);
myButton.graphics.endFill();
addChild(myButton);
myButton.addEventListener(MouseEvent.CLICK, button_fn);
function button_fn(e:MouseEvent): void {
my_FLVPlybk.stop();
};
Type the code below, starting at the next line in the Actions editor, to create and place an instance of a MovieClip object that is drawn with a pixel line width of 4 pixels, is filled with the color green, is the shape of a rectangle (positioned at stage coordinates [350,250] with a width of 50 pixels and a height of 20 pixels), and will call a function that will play the video when the MovieClip object(myButton1) is clicked with the mouse.
var myButton1:MovieClip = new MovieClip();
myButton1.graphics.lineStyle(4);
myButton1.graphics.beginFill(0x00FF00);
myButton1.graphics.drawRect(350, 250, 50, 20);
myButton1.graphics.endFill();
addChild(myButton1);
myButton1.addEventListener(MouseEvent.CLICK, button1_fn);
function button1_fn(e:MouseEvent): void {
my_FLVPlybk.play();
};
Copy and paste the code below into the Actions editor if you want the video player program to not have any syntax errors and to run correctly the first time.
import fl.video.*;
var my_FLVPlybk = new FLVPlayback();
my_FLVPlybk.x = 25;
my_FLVPlybk.y = 50;
my_FLVPlybk.source = "http://www.helpexamples.com/flash/video/water.flv";
addChild(my_FLVPlybk);
var myButton:MovieClip = new MovieClip();
myButton.graphics.lineStyle(4);
myButton.graphics.beginFill(0xFF0000);
myButton.graphics.drawRect(350, 200, 50, 20);
myButton.graphics.endFill();
addChild(myButton);
myButton.addEventListener(MouseEvent.CLICK, button_fn);
function button_fn(e:MouseEvent): void {
my_FLVPlybk.stop();
};
var myButton1:MovieClip = new MovieClip();
myButton1.graphics.lineStyle(4);
myButton1.graphics.beginFill(0x00FF00);
myButton1.graphics.drawRect(350, 250, 50, 20);
myButton1.graphics.endFill();
addChild(myButton1);
myButton1.addEventListener(MouseEvent.CLICK, button1_fn);
function button1_fn(e:MouseEvent): void {
my_FLVPlybk.play();
};
Click the "TestMovie" option in the Control menu on the main Flash menu bar to load the video at example.com and play the video on the Flash stage. Click the red button to stop the video from playing, and then click the green button to continue playing the video. Click the green button again to play the video again after the video has ended.