Posted by sortofme on April 30th, 2008
Actionscript:
-
<pre>
-
package {
-
-
import com.onebyonedesign.extras.VideoLoop;
-
import flash.display.Sprite;
-
import flash.events.AsyncErrorEvent;
-
import flash.events.Event;
-
import flash.events.MouseEvent;
-
import flash.text.AntiAliasType;
-
import flash.text.TextField;
-
import flash.text.TextFieldAutoSize;
-
import flash.text.TextFormat;
-
import flash.text.TextFormatAlign;
-
-
public class Main extends Sprite {
-
-
private var isPlaying:Boolean = true;
-
private var videoLoop:VideoLoop;
-
-
public function Main():void {
-
videoLoop = new VideoLoop("water.flv");
-
videoLoop.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
-
addChild(videoLoop);
-
-
stage.addEventListener(MouseEvent.CLICK, adjustVideo);
-
-
var info:TextField = new TextField();
-
info.selectable = false;
-
info.autoSize = TextFieldAutoSize.LEFT;
-
info.antiAliasType = AntiAliasType.ADVANCED;
-
var fmt:TextFormat = new TextFormat("_sans", 12, 0x939393);
-
fmt.align = TextFormatAlign.CENTER;
-
info.defaultTextFormat = fmt;
-
info.text = "Two second video looped.\nClick to pause/resume.";
-
info.x = 95;
-
info.y = 190;
-
-
addChild(info);
-
}
-
-
private function onAsyncError(aee:AsyncErrorEvent):void {
-
// handle annoying async errors (such as the missing metadata property) here.
-
}
-
-
private function adjustVideo(me:MouseEvent):void {
-
if (isPlaying) {
-
videoLoop.pause();
-
} else {
-
videoLoop.play();
-
}
-
isPlaying = !isPlaying;
-
}
-
}
-
}</pre>
Recent Comments