EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 606

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
606 Working with Images, Sound, and Video
Playing back external FLV files dynamically
You can load FLV files at runtime to play in a SWF file. You can load them into a video
object or into a component such as the FLVPlayback component. The following example
shows how to play back a file named clouds.flv in a video object.
To play back an external FLV file in a Flash document:
1. Create a new Flash document called playFLV.fla.
2. In the Library panel (Window > Library), select New Video from the Library
pop-up menu.
3. In the Video Properties dialog box, name the video symbol and select Video (ActionScript
controlled).
4. Click OK to create a video object.
5. Drag the video object from the Library panel to the Stage to create a video object instance.
6. With the video object selected on the Stage, type my_video in the Instance Name text box
in the Property inspector (Window > Properties > Properties).
7. Select Frame 1 in the Timeline, and open the Actions panel (Window > Actions).
8. Type the following code in the Actions panel:
this.createTextField("status_txt", 999, 0, 0, 100, 100);
status_txt.autoSize = "left";
status_txt.multiline = true;
// Create a NetConnection object
var my_nc:NetConnection = new NetConnection();
// Create a local streaming connection
my_nc.connect(null);
// Create a NetStream object and define an onStatus() function
var my_ns:NetStream = new NetStream(my_nc);
my_ns.onStatus = function(infoObject:Object):Void {
status_txt.text += "status (" + this.time + " seconds)\n";
status_txt.text += "\t Level: " + infoObject.level + "\n";
status_txt.text += "\t Code: " + infoObject.code + "\n\n";
};
// Attach the NetStream video feed to the Video object
my_video.attachVideo(my_ns);
// Set the buffer time
my_ns.setBufferTime(5);
// Begin playing the FLV file
my_ns.play("http://www.helpexamples.com/flash/video/clouds.flv");
9.
Select Control > Test Movie to test the document.

Table of Contents

Related product manuals