video playback
This commit is contained in:
parent
0757363573
commit
9110fc006a
14
src/Main.as
14
src/Main.as
|
@ -13,10 +13,12 @@ package
|
||||||
{
|
{
|
||||||
private var clickarea:ClickArea;
|
private var clickarea:ClickArea;
|
||||||
private var sketchShape:SketchShape;
|
private var sketchShape:SketchShape;
|
||||||
|
private var videotube:Videotube;
|
||||||
public function Main():void
|
public function Main():void
|
||||||
{
|
{
|
||||||
clickarea = new ClickArea([new Point(50, 50), new Point(100, 80), new Point(30, 120)], 0x555555);
|
clickarea = new ClickArea([new Point(50, 50), new Point(100, 80), new Point(30, 120)], 0x555555);
|
||||||
sketchShape = new SketchShape();
|
sketchShape = new SketchShape();
|
||||||
|
videotube = new Videotube();
|
||||||
if (stage) init();
|
if (stage) init();
|
||||||
else addEventListener(Event.ADDED_TO_STAGE, init);
|
else addEventListener(Event.ADDED_TO_STAGE, init);
|
||||||
}
|
}
|
||||||
|
@ -25,21 +27,27 @@ package
|
||||||
{
|
{
|
||||||
removeEventListener(Event.ADDED_TO_STAGE, init);
|
removeEventListener(Event.ADDED_TO_STAGE, init);
|
||||||
// entry point
|
// entry point
|
||||||
|
addChild(videotube);
|
||||||
addChild(clickarea);
|
addChild(clickarea);
|
||||||
addChild(sketchShape);
|
addChild(sketchShape);
|
||||||
addEventListener(MouseEvent.CLICK, onClick);
|
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
|
private function onClick(e: MouseEvent): void
|
||||||
{
|
{
|
||||||
if (clickarea.FHit(new Point(e.stageX, e.stageY)))
|
if (clickarea.FHit(new Point(e.stageX, e.stageY)))
|
||||||
clickarea.Toggle();
|
clickarea.Toggle();
|
||||||
}
|
}
|
||||||
|
private function onShapeBegin(e: Event): void
|
||||||
|
{
|
||||||
|
videotube.stream.pause();
|
||||||
|
}
|
||||||
private function onShapeComplete(e: Event): void
|
private function onShapeComplete(e: Event): void
|
||||||
{
|
{
|
||||||
addChild(new ClickArea(sketchShape.rgpoint, 0x883388, 0.5));
|
addChild(new ClickArea(sketchShape.rgpoint, 0x883388, 0.5));
|
||||||
sketchShape.clear();
|
videotube.stream.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,6 +16,10 @@ package
|
||||||
private var shape: Shape;
|
private var shape: Shape;
|
||||||
private var shapeLine: Shape;
|
private var shapeLine: Shape;
|
||||||
private var msClickLast: int;
|
private var msClickLast: int;
|
||||||
|
|
||||||
|
public static const DRAW_BEGIN:String = "draw-begin";
|
||||||
|
public static const DRAW_END:String = "draw-end";
|
||||||
|
|
||||||
public function SketchShape()
|
public function SketchShape()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@ -28,6 +32,7 @@ package
|
||||||
}
|
}
|
||||||
private function init(e: Event):void
|
private function init(e: Event):void
|
||||||
{
|
{
|
||||||
|
removeEventListener(Event.ADDED_TO_STAGE, init);
|
||||||
stage.doubleClickEnabled = true;
|
stage.doubleClickEnabled = true;
|
||||||
stage.addEventListener(MouseEvent.CLICK, onClick);
|
stage.addEventListener(MouseEvent.CLICK, onClick);
|
||||||
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
|
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
|
||||||
|
@ -48,7 +53,7 @@ package
|
||||||
var dmsClick:int = msClickNow - msClickLast;
|
var dmsClick:int = msClickNow - msClickLast;
|
||||||
if (dmsClick < 200)
|
if (dmsClick < 200)
|
||||||
{
|
{
|
||||||
dispatchEvent(new Event(Event.COMPLETE));
|
dispatchEvent(new Event(DRAW_END));
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -57,6 +62,7 @@ package
|
||||||
{
|
{
|
||||||
shapeLine = new Shape();
|
shapeLine = new Shape();
|
||||||
addChild(shapeLine);
|
addChild(shapeLine);
|
||||||
|
dispatchEvent(new Event(DRAW_BEGIN));
|
||||||
}
|
}
|
||||||
rgpoint.push(new Point(e.stageX, e.stageY));
|
rgpoint.push(new Point(e.stageX, e.stageY));
|
||||||
redrawShape();
|
redrawShape();
|
||||||
|
|
33
src/Videotube.as
Normal file
33
src/Videotube.as
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue