Actionscript:
  1. <pre>
  2. package {
  3.  
  4.     import com.onebyonedesign.extras.VideoLoop;
  5.     import flash.display.Sprite;
  6.     import flash.events.AsyncErrorEvent;
  7.     import flash.events.Event;
  8.     import flash.events.MouseEvent;
  9.     import flash.text.AntiAliasType;
  10.     import flash.text.TextField;
  11.     import flash.text.TextFieldAutoSize;
  12.     import flash.text.TextFormat;
  13.     import flash.text.TextFormatAlign;
  14.  
  15.     public class Main extends Sprite {
  16.  
  17.         private var isPlaying:Boolean = true;
  18.         private var videoLoop:VideoLoop;
  19.  
  20.         public function Main():void {
  21.             videoLoop = new VideoLoop("water.flv");
  22.             videoLoop.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
  23.             addChild(videoLoop);
  24.  
  25.             stage.addEventListener(MouseEvent.CLICK, adjustVideo);
  26.  
  27.             var info:TextField = new TextField();
  28.             info.selectable = false;
  29.             info.autoSize = TextFieldAutoSize.LEFT;
  30.             info.antiAliasType = AntiAliasType.ADVANCED;
  31.             var fmt:TextFormat = new TextFormat("_sans", 12, 0x939393);
  32.             fmt.align = TextFormatAlign.CENTER;
  33.             info.defaultTextFormat = fmt;
  34.             info.text = "Two second video looped.\nClick to pause/resume.";
  35.             info.x = 95;
  36.             info.y = 190;
  37.  
  38.             addChild(info);
  39.         }
  40.  
  41.         private function onAsyncError(aee:AsyncErrorEvent):void {
  42.             //  handle annoying async errors (such as the missing metadata property) here.
  43.         }
  44.  
  45.         private function adjustVideo(me:MouseEvent):void {
  46.             if (isPlaying) {
  47.                 videoLoop.pause();
  48.             } else {
  49.                 videoLoop.play();
  50.             }
  51.             isPlaying = !isPlaying;
  52.         }
  53.     }
  54. }</pre>