O'Reilly logo

Learning ActionScript 3.0 by Zevan Rosser, Rich Shupe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Coding Your Own Video Playback

Up to this point, we've relied exclusively on components for FLV playback. However, it's important to reiterate that creating your own code can reduce file size, allow you to customize your own functionality, and free you from relying on the FLVPlayback component for user interface controls. Code-only solutions are advantageous for these reasons. However, they do have design limitations because code-only files can't use your own custom art. Therefore, using code-only approaches should be the result of a balanced analysis of their pros and cons, rather than the ultimate goal in every situation.

This last section of this chapter provides a complete class called BasicVideo to create a very simple video player entirely from code. Even the buttons are drawn dynamically, using techniques discussed in Chapter 8. As a result, the generated SWF file is only 4 K. As usual, this class can be created in any text editor and should be saved in a text file called BasicVideo.as.

1 package { 2 3 import flash.display.*; 4 import flash.net.*; 5 import flash.media.Video; 6 import flash.events.*; 7 import CreateRoundRectButton; 8 9 public class BasicVideo extends Sprite { 10 11 private var _vidConnection:NetConnection; 12 private var _vidStream:NetStream; 13 private var _vid:Video; 14 private var _vidURL:String; 15 private var _vidPlaying:Boolean; 16 private var _infoClient:Object; 17 private var _playBtn:Sprite; 18 private var _pauseBtn:Sprite; 19 private var _stopBtn:Sprite; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required