diff --git a/src/Main.as b/src/Main.as index 9786159..657018a 100644 --- a/src/Main.as +++ b/src/Main.as @@ -13,10 +13,12 @@ package { private var clickarea:ClickArea; private var sketchShape:SketchShape; + private var videotube:Videotube; public function Main():void { clickarea = new ClickArea([new Point(50, 50), new Point(100, 80), new Point(30, 120)], 0x555555); sketchShape = new SketchShape(); + videotube = new Videotube(); if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } @@ -25,21 +27,27 @@ package { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point + addChild(videotube); addChild(clickarea); addChild(sketchShape); addEventListener(MouseEvent.CLICK, onClick); - sketchShape.addEventListener(Event.COMPLETE, onShapeComplete); + sketchShape.addEventListener(SketchShape.DRAW_BEGIN, onShapeBegin); + sketchShape.addEventListener(SketchShape.DRAW_END, onShapeComplete); + videotube.stream.play("The Last Eichhof - Longplay.flv"); } private function onClick(e: MouseEvent): void { if (clickarea.FHit(new Point(e.stageX, e.stageY))) clickarea.Toggle(); } + private function onShapeBegin(e: Event): void + { + videotube.stream.pause(); + } private function onShapeComplete(e: Event): void { addChild(new ClickArea(sketchShape.rgpoint, 0x883388, 0.5)); - sketchShape.clear(); + videotube.stream.resume(); } } - } \ No newline at end of file diff --git a/src/SketchShape.as b/src/SketchShape.as index 380240a..bfd7199 100644 --- a/src/SketchShape.as +++ b/src/SketchShape.as @@ -16,6 +16,10 @@ package private var shape: Shape; private var shapeLine: Shape; private var msClickLast: int; + + public static const DRAW_BEGIN:String = "draw-begin"; + public static const DRAW_END:String = "draw-end"; + public function SketchShape() { super(); @@ -28,6 +32,7 @@ package } private function init(e: Event):void { + removeEventListener(Event.ADDED_TO_STAGE, init); stage.doubleClickEnabled = true; stage.addEventListener(MouseEvent.CLICK, onClick); stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove); @@ -48,7 +53,7 @@ package var dmsClick:int = msClickNow - msClickLast; if (dmsClick < 200) { - dispatchEvent(new Event(Event.COMPLETE)); + dispatchEvent(new Event(DRAW_END)); clear(); } else @@ -57,6 +62,7 @@ package { shapeLine = new Shape(); addChild(shapeLine); + dispatchEvent(new Event(DRAW_BEGIN)); } rgpoint.push(new Point(e.stageX, e.stageY)); redrawShape(); diff --git a/src/Videotube.as b/src/Videotube.as new file mode 100644 index 0000000..d159043 --- /dev/null +++ b/src/Videotube.as @@ -0,0 +1,33 @@ +package +{ + import flash.display.Sprite; + import flash.events.Event; + import flash.media.Video; + import flash.net.NetConnection; + import flash.net.NetStream; + /** + * ... + * @author jjp + */ + public class Videotube extends Sprite + { + private var flv:Video; + public var stream:NetStream; + public function Videotube() + { + super(); + addEventListener(Event.ADDED_TO_STAGE, init); + } + private function init(e: Event):void + { + removeEventListener(Event.ADDED_TO_STAGE, init); + flv = new Video(stage.stageWidth, stage.stageHeight); + addChild(flv); + var conn:NetConnection = new NetConnection(); + conn.connect(null); + stream = new NetStream(conn); + stream.client = new Object(); + flv.attachNetStream(stream); + } + } +} \ No newline at end of file