source(s)
[Bindable]
private var index:int = 0;
private var max:uint = 12;
public var video:Array = [
"../assets/clips/tube/balloon.flv",
"../assets/clips/tube/web20.flv",
"../assets/clips/tube/china/calligraphy.flv",
"../assets/clips/blip/rgbxyz.flv",
"../assets/clips/shout/strangest.flv",
"../assets/clips/tube/design-coding.flv",
"../assets/clips/tube/baby-laugh.flv",
"../assets/clips/tube/america.flv",
"../assets/clips/tube/bowie-tibet.flv",
"../assets/clips/tube/strings.flv",
//"../assets/clips/tube/muto-wall.flv",
"../assets/clips/tube/starwars-struggle.flv",
"../assets/clips/tube/climafutura.flv"
//"../assets/im/08/clip/roundup.flv"
];
[Bindable]
public var source:String = video[index];
private function plus( event:MouseEvent ):void
{
clear(myVid);
state = 0; off = 0;
index += 1;
if (index > (max-1)) index = 0;
myVid.stop();
movie = video[index]; // bindable
myVid.play();
}
private function minus( event:MouseEvent ):void
{
clear(myVid);
state = 0; off = 0;
index = index - 1;
if (index < 0) index = max-1;
myVid.stop();
movie = video[index]; // bindable
myVid.play();
}
paint(s)
private var new_size_influence:Number = 0.5;
private var mid_point_push:Number = .75;
private var max_line_width:Number = (Math.random() * 10) + 10;
//private var info.visible:Boolean = false;
private var curves:Array;
private var start_x:Number;
private var start_y:Number;
private var mid_x:Number;
private var mid_y:Number;
private var end_x:Number;
private var end_y:Number;
private var distance:Number;
private var new_size:Number;
private var parity:Boolean;
private var size:Number = 0;
private var splat:uint = 0xFF0000;
private var aggression:Number = 8.4; // 12.4;//3.4;
private var painting:Sprite;
private var dopaint:int = 0;
init(s)
private function init() : void {
avx = new Array();
avy = new Array();
arz = new Array();
myVid.source = movie;
off = 1;
var h:Number = systemManager.stage.stageHeight;
var w:Number = systemManager.stage.stageWidth;
ball.graphics.beginFill(0xff0000);
ball.graphics.drawCircle(0, 0, radius);
ball.x = 200;
ball.y = 200;
//avx.push(Math.random() * 30 - 5);
//avy.push(-20);
//slist.addChild(ball);
sprites = new Array();
//sprites.push(ball);
oval = new object_ax_oval();
//slist.addChild(bill);
// var bx:Sprite = new animation_ch03_Oval();
// var bx:Sprite = new animation_ch11_Billiard3();
cloud = new object_ax_cloud(myVid);
obounce = new object_ax_bounce(myVid);
slist.addChild(obounce);
//slist.addChild(oval);
sprites.push(oval);
myVid.addChild(slist);
//myVid.mask = slist;
painting = new Sprite();
myVid.addChild(painting);
start_x = mid_x = end_x = 250; //stage.stageWidth / 2;
start_y = mid_y = end_y = 250; //stage.stageHeight / 2;
//addEventListener(Event.ENTER_FRAME, paint);
//addEventListener(MouseEvent.CLICK, change_color);
addEventListener(Event.ENTER_FRAME, frame);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
}
mode(s)
[Bindable] private var _mode:Object = "0";
private var has_cloud:uint = 0;
private var has_oval:uint = 0;
private var has_collide:uint = 0;
private var has_bounce:uint = 1;
private var has_ball:uint = 0;
[Bindable] private var _art:Object = "0";
private function art(event:Event):void {
_art = event.target.text;
//story.text = "art: " + event.target.text;
if (_art == "O") {
} else if (_art == "A") {
glow();
} else if (_art == "R") {
color();
} else if (_art == "T") {
stop();
} else { }
}
private function mode(event:Event):void {
_mode = event.target.text;
//story.text = "mode: " + event.target.text;
if (_mode == "1") {
} else if (_mode == "3") {
stop();
} else if (_mode == "4") {
color();
} else if (_mode == "5") {
glow();
} else if (_mode == "6") {
if (has_collide == 1) { has_collide = 0; }
else { has_collide = 1; }
} else if (_mode == "7") {
if (has_bounce == 1) { slist.removeChild(obounce); has_bounce = 0; }
else { has_bounce = 1; slist.addChild(obounce); }
} else if (_mode == "8") {
if (has_oval == 1) { slist.removeChild(oval); has_oval = 0; }
else { has_oval = 1; slist.addChild(oval); }
} else if (_mode == "9") {
if (has_cloud == 1) { slist.removeChild(cloud); has_cloud = 0; }
else { has_cloud = 1; slist.addChild(cloud); }
} else { _mode="0"; }
}
effect(s)
private function stop() : void {
myVid.filters = [];
}
private function draw() : void {
myVid.filters = [];
}
private var conv:uint = 0;
private function glow() : void {
//myVid.filters = [new GlowFilter(0xff1122)];
var matrix:Array = [ 0,1,0, 1,5,1, 0,1,0 ];
switch (conv) {
case 0:
matrix = [ 0,0,0, 0,2,0, 0,0,0 ];
myVid.filters = [new ConvolutionFilter(3,3,matrix)];
break;
case 1:
matrix = [ -1,-1,-1, -1,8,-1, -1,-1,-1 ];
myVid.filters = [new ConvolutionFilter(3,3,matrix)];
break;
case 2:
matrix = [ -1,-1,-1, -1,5,-1, 1,-1,1 ];
myVid.filters = [new ConvolutionFilter(3,3,matrix)];
break;
case 3:
matrix = [ 1,1,1, 1,8,1, 1,1,1 ];
myVid.filters = [new ConvolutionFilter(3,3,matrix)];
break;
case 4:
matrix = [ -1,-1,-1, -1,4,0, 0,0,0 ];
myVid.filters = [new ConvolutionFilter(3,3,matrix)];
break;
case 5:
matrix = [ 0,0,0, 1,5,-1, -1,-1,-1 ];
myVid.filters = [new ConvolutionFilter(3,3,matrix)];
break;
default:
matrix = [ -2,-1,0, -1,4,1, 0,1,2 ];
myVid.filters = [new ConvolutionFilter(3,3,matrix)];
conv = 0;
break;
}
conv += 1;
}
private var on:uint = 0;
private function color() : void {
var red:Number = Math.random() * 255;
var green:Number = Math.random() * 255;
var blue:Number = Math.random() * 255;
if (on == 0) {
on = 1; myVid.transform.colorTransform = new ColorTransform(-1, -1, -1, 1, red, green, blue, 0);
} else {
on = 0; myVid.transform.colorTransform = new ColorTransform();
}
}
splatter(s)
private var togsplat:int = 0;
private function change_color(event:MouseEvent):void{
var h:Number = systemManager.stage.height;
var w:Number = systemManager.stage.width;
if (mouseY < h-50 && mouseY > 50 &&
mouseX < w-50 && mouseX > 50) {
//color = Math.random() * 0xFFFFFF;
//txt.text = "Color: 0x" + color.toString();
//if (togsplat == 1) {
toggle_painting();
//}
}
}
private function start_painting():void{
dopaint = 1;
addEventListener(Event.ENTER_FRAME, paint);
}
private function stop_painting():void{
dopaint = 0;
removeEventListener(Event.ENTER_FRAME, paint);
}
private function toggle_painting():void{
if (dopaint == 0) start_painting(); else stop_painting();
}
public function paint(event:Event):void {
//counter++;
//txt.text = counter.toString();
//if (with_wii == 0) {
//vpX = mouseX;
//vpY = mouseY;
//}
splat = Math.random() * 0xFFFFFF;
//AE
//graphics.lineTo(mouseX, mouseY);
The code for the paint function was ported and adapted from:
"Splatter", by Stamen Design
http://stamen.com/projects/splatter
*
mid_x = ((end_x - start_x) * (1 + mid_point_push)) + start_x;
mid_y = ((end_y - start_y) * (1 + mid_point_push)) + start_y;
start_x = end_x;
start_y = end_y;
//end_x = vpX;// = mouseX;
//end_y = vpY;// = mouseY;
end_x = mouseX;
end_y = mouseY;
distance = Math.sqrt(Math.pow((end_x - start_x), 2) + Math.pow((end_y - start_y), 2));
new_size = max_line_width / distance;
size = aggression*new_size;//(new_size_influence * new_size) + ((1 - new_size_influence) * size);
splatter(painting.graphics, start_x, start_y, end_x, end_y, mid_x, mid_y, size);
parity = false;
/*
_parent.new_size_influence += ((Math.random() * 0.1) - 0.05);
_parent.mid_point_push += ((Math.random() * 0.1) - 0.05);
_parent.max_line_width += ((Math.random() * 4) - 2);
*/
new_size_influence += ((Math.random() * 0.1) - 0.05);
mid_point_push += ((Math.random() * 0.1) - 0.05);
max_line_width += ((Math.random() * 4) - 2);
}
private function splatter(obj:Graphics, x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, d:Number):void {
//var obj:Graphics = painting.graphics;
obj.lineStyle(d, splat, 100);
//txt.text = d.toString();
obj.moveTo(x1, y1);
obj.curveTo(x3, y3, x2, y2);
//curves.push([x1, y1, x3, y3, x2, y2, d]);
// splotch
var dd:Number = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
for (var i:uint = 0; i<Math.floor(5*Math.pow(Math.random(), 4)); i++) {
// positioning of splotch varies between ±4dd, tending towards 0
var splat_range:Number = 1;
var x4:Number = dd * 1 * (Math.pow(Math.random(), splat_range) - (splat_range/2));
var y4:Number = dd * 1 * (Math.pow(Math.random(), splat_range) - (splat_range/2));
// direction of splotch varies between ±0.5
var x5:Number = Math.random() - 0.5;
var y5:Number = Math.random() - 0.5;
var d_:Number = d*(0.5+Math.random());
obj.lineStyle(d_, splat, 100);
obj.moveTo((x1+x4), (y1+y4));
obj.lineTo((x1+x4+x5), (y1+y4+y5));
//curves.push([(x1+x4), (y1+y4), (x1+x4+x5), (y1+y4+y5), (x1+x4+x5), (y1+y4+y5), d_]);
}
//addChild(obj); //?AE
}
frame(s)
private function frame(event:Event):void {
var h:Number = systemManager.stage.height;
var w:Number = systemManager.stage.width;
for(var i:uint = 0; i < smax; i++) {
vx = avx[i]; vy = avy[i];
var dx:Number = 0; //Math.random() * 2 - 1;
var dy:Number = 0; //Math.random() * 2 - 1 ;
vx += dx; vy += dy + gravity;
var s:Number = w/800;
var left:Number = 0;
var right:Number = myVid.width;
var top:Number = 0;
var bottom:Number = myVid.height;
oval.centerX = right/2;
oval.centerY = bottom/2;
oval.radiusX = right/3;
oval.radiusY = bottom/4;
oval.adjust(s);
//cloud.x = right / 2;
//cloud.centerX = right/2;
//cloud.centerY = bottom/2;
//cloud.radiusX = right/3;
//cloud.radiusY = bottom/4;
//cloud.size = s;
// for(var i:uint = 0; i < 2; i++) {
var ball:Sprite = sprites[i];
var bounds:Rectangle = ball.getBounds(myVid);
ball.x += vx;
ball.y += vy;
var cx:Number = bounds.x + bounds.width/2;
var cy:Number = bounds.y + bounds.height/2;
if (has_collide == 1) {
for(var j:uint = i; j < smax; j++) {
var other:Rectangle = sprites[j].getBounds(myVid);
var ocx:Number = other.x + other.width/2;
var ocy:Number = other.y + other.height/2;
if (((bounds.right > other.left && cx < other.left) && ((bounds.bottom > other.top && cy < other.top) || (bounds.top < other.bottom && cy > other.bottom)) ) ||
((bounds.left < other.right && cx > other.right) && ((bounds.bottom > other.top && cy < other.top) || (bounds.top < other.bottom && cy > other.bottom))) )
{
var ddx:Number = cx - ocx;
var ddy:Number = cy - ocy;
if (ddx*ddx < ddy*ddy) {
vx *= bounce; avx[j] *= bounce;
ball.x += 3 * vx;
} else { vy *= bounce; avy[j] *= bounce;
ball.y += 3 * vy;
}
}
}
}
if((bounds.right > right) || (bounds.left < left))
{
vx *= bounce;
ball.x += 5 * vx;
}
if((bounds.bottom > bottom) || (bounds.top < top))
{
vy *= bounce;
ball.y += 5 * vy;
}
avx[i] = vx; avy[i] = vy;
}
}
mouse
private var drawing:uint = 0;
private function onMouseDown(event:MouseEvent):void
{
var h:Number = systemManager.stage.height;
var w:Number = systemManager.stage.width;
if (mouseY < h-50 && mouseY > 50 &&
mouseX < w-50 && mouseX > 50) {
drawing = 1;
// myVid.mask = null;
// story.text = "m:" + mouseX + " " + mouseY;
oldX = mouseX; oldY = mouseY;
ball = new Sprite();
myVid.addChild(ball);
//panel.addChild(ball);
square = new Sprite();
slist.addChild(square);
ball.graphics.moveTo(mouseX, mouseY);
ball.graphics.lineStyle(4,0xff0000);
//ball.graphics.beginFill(0xff0000);
square.graphics.moveTo(mouseX, mouseY);
square.graphics.beginFill(0xff0000);
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
//story.text = "m:" + mouseX + " " + mouseY;
}
}
private function onMouseUp(event:MouseEvent):void
{
smax += 1;
story.text = "";
square.graphics.endFill();
slist.addChild(square);
myVid.removeChild(ball);
avx.push(Math.random() * 20 - 5);
avy.push(-5);
arz.push(Math.random() * 0.2 - 0.1);
sprites.push(square);
myVid.mask = slist;
removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
var bounds:Rectangle = square.getBounds(myVid);
// story.text = "s: " + square.x + "/" + square.y + "(" + bounds.left + "," + bounds.top + "," + bounds.width + "," + bounds.height + ")";
}
private function onMouseMove(event:MouseEvent):void
{
if (drawing == 1) {
square.graphics.lineTo(mouseX, mouseY);
ball.graphics.lineTo(mouseX, mouseY);
// square.graphics.drawCircle(mouseX, mouseY, 10);
// story.text = "m:" + mouseX + " " + mouseY;
} else { story.text = "???"; }
}
hide
private var peep:uint = 0;
private function hide(video:Object):void {
if (peep == 0) {
myVid.removeChild(slist);
myVid.mask = null;
peep = 1;
removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
removeEventListener(Event.ENTER_FRAME, frame);
addEventListener(MouseEvent.CLICK, change_color);
//addEventListener(Event.ENTER_FRAME, paint);
} else {
peep = 0;
myVid.addChild(slist);
myVid.mask = slist;
removeEventListener(MouseEvent.CLICK, change_color);
//removeEventListener(Event.ENTER_FRAME, paint);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(Event.ENTER_FRAME, frame);
}
}
cuepoint(s)
[Bindable] private var cuepoints:Array = [
{name:'cue 0', time:1.00},
{name:'cue 1', time:2.00},
{name:'cue 2', time:3.00},
{name:'cue 3', time:4.00},
];
[Bindable] private var info:String = "cue -";
[Bindable] private var show:uint = 0;
clear
private function clear(video:Object):void {
// stop();
story.text = "";
sub.text = "";
if (show == 0) {
show = 1; tileList.visible = false;
arrColl.removeAll();
tileList.invalidateList();
}
else { show = 0; tileList.visible = true; }
}
select
private function select(event:Event):void {
myVid.close();
tileList.visible = false;
arrColl.removeAll();
tileList.invalidateList();
tileList.visible = true;
show = 0;
// movie = input.text;
myVid.source = movie;
myVid.cuePoints = cuepoints;
story.text = movie;
myVid.play();
off = 0;
state = 0;
}
cue(s)
private function cue(evt:Object):void {
if (show == 1) { show = 0; tileList.visible = true; }
var pad:String = " ";
var bm:Bitmap = copy(myVid as DisplayObject);
var time:String = format(myVid.playheadTime);
if (state < 3) info = cuepoints[state].name;
if (state == 0) { story.text = "click ! to annotate ..."; }
else if (state == 1) { story.text = "creative technolog "; }
else if (state == 2) { story.text = "new media "; }
else { off = 1; story.text = ""; info="cue " + state; }
arrColl.addItem({pad:pad, bitmap:bm, info:info, time:time});
state += 1;
if (off == 1) story.text = "";
}
copy / format
private function copy(source:DisplayObject):Bitmap {
var bmd:BitmapData = new BitmapData(source.width, source.height);
bmd.draw(source);
return new Bitmap(bmd);
}
private function format(value:Number):String{
var sec:int = (value * 60) / 60;
var mil:int = (value - sec) * 100;
var result:String = sec.toString() + "." + mil.toString();
return result;
}
]]>
</mx:Script>
display
<mx:VideoDisplay x="0" y="0" id="myVid" source="{movie}" height="100%" width="100%" autoPlay="false"
cuePointManagerClass="mx.controls.videoClasses.CuePointManager"
cuePoint="cue(event)"
/>
<mx:Label text="{movie} / {index}" color="gray" bottom="25" left="3" click="clear(myVid);"/>
<mx:HBox top="5" right="3">
<mx:Label text="{state} / {movie} " color="grey" top="bottom=20" left="3"/>
<mx:Label color="gray" text="@" click="attach(myVid);"/>
</mx:HBox>
<mx:HBox top="5" left="3">
<mx:VBox>
<mx:Label color="gray" text="?" click="hide(myVid);"/>
<mx:Label color="gray" text="1" click="mode(event);"/>
<mx:Label color="gray" text="2" click="mode(event);"/>
<mx:Label color="gray" text="3" click="mode(event);"/>
<mx:Label color="gray" text="4" click="mode(event);"/>
<mx:Label color="gray" text="5" click="mode(event);"/>
<mx:Label color="gray" text="6" click="mode(event);"/>
<mx:Label color="gray" text="7" click="mode(event);"/>
<mx:Label color="gray" text="8" click="mode(event);"/>
<mx:Label color="gray" text="9" click="mode(event);"/>
</mx:VBox>
<mx:Label text="[{_art}/{_mode}]:{state} : {format(myVid.playheadTime)} / {info}" color="gray" top="10" left="20"/>
</mx:HBox>
<mx:Label id="story" text="" color="white" top="75" left="100" fontSize="15"/>
<mx:Label id="sub" text="" color="white" top="115" left="120" fontSize="12"/>
controls
<mx:HBox left="3" bottom="5">
<mx:Label color="gray" text="!" click="cue(myVid);"/>
<mx:Button color="gray" borderColor="0" fillAlphas="[0,0]" label="+" click="plus(event);"/>
<mx:Button color="gray" borderColor="0" fillAlphas="[0,0]" label="-" click="minus(event);"/>
<mx:Button color="gray" borderColor="0" fillAlphas="[0,0]" label="/" click="clear(myVid);"/>
<mx:Label color="gray" text="A" click="art(event);"/>
<mx:Label color="gray" text="R" click="art(event);"/>
<mx:Label color="gray" text="T" click="art(event);"/>
</mx:HBox>
<mx:HBox right="3" bottom="5">
<mx:Button color="gray" borderColor="0" fillAlphas="[0, 0]" label=">" click="myVid.play();"/>
<mx:Button color="gray" borderColor="0" fillAlphas="[0, 0]" label="||" click="myVid.pause();"/>
<mx:Label color="gray" text="#" click="display.toggle();"/>
</mx:HBox>
<mx:Label text="ViP AEliëns (C)" color="gray" bottom="25" right="3" click="hide(myVid);"/>
<mx:Canvas id="panel" x="0" y="0" height="100%" width="100%"
backgroundAlpha="0.3" borderColor="0" borderThickness="0"/>
tile(s)
<mx:TileList
top="50" right="10"
backgroundAlpha="0"
borderColor="0"
borderThickness="0"
id="tileList"
columnCount="1" dataProvider="{arrColl}"
width="170"
height="{myVid.height - 100 }"
verticalScrollPolicy="off">
<mx:itemRenderer>
<mx:Component>
<mx:HBox right="0" paddingBottom="0" paddingTop="0">
<mx:Text textAlign="right">
<mx:htmlText>
<br;\ >
name: {data.info}
time: {data.time}
</mx:htmlText>
</mx:Text>
<mx:HBox right="0">
<mx:Image width="80" height="60" source="{data.bitmap}" toolTip="{data.time}"
maintainAspectRatio="false"
/>
</mx:HBox>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:TileList>
</mx:Application>