flash on 2010-5-28
/**
* Copyright yd_niku ( http://wonderfl.net/user/yd_niku )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/kBxK
*/
package {
import flash.display.Sprite;
import frocessing.display.*;
import flash.geom.*;
public class FlashTest extends F5MovieClip2DBmp{
public function FlashTest() {
super();
}
private var n:int = 2;
private var t:Number = 0;
public function setup():void{
size( stage.stageWidth, stage.stageHeight);
background(0);
noFill();
stroke( 255, 0.1 );
var p:Sprite = new Ball(-100,232);
addChild(p);
p = new Ball(10,232);
addChild(p);
_points.push(p);
p = new Ball(232,10);
addChild(p);
_points.push(p);
p = new Ball(446,232);
addChild(p);
_points.push(p);
}
private var _points:Vector.<Sprite> = new Vector.<Sprite>();
public function draw():void{
background(0);
beginShape();
curveVertex( -100, 232 );
for each( var p:Sprite in _points ){
curveVertex(p.x,p.y);
}
curveVertex( 500, 232 );
endShape();
beginShape();
curveVertex( -100, 232 );
for each( var p:Sprite in _points ){
curveVertex(p.x+Math.sin(t)*3,p.y+Math.cos(t)*3);
}
curveVertex( 500, 232 );
endShape();
t+=0.05;
}
}
}
import flash.display.*;
import flash.events.*;
class Ball extends Sprite{
public function Ball(sx:Number,sy:Number){
graphics.beginFill(0xFFFFFF);
graphics.drawCircle(0,0,4);
graphics.endFill();
x = sx;
y = sy;
addEventListener(MouseEvent.MOUSE_DOWN,mouseDown);
}
private function mouseDown(e:Event):void{
startDrag();
addEventListener(MouseEvent.MOUSE_UP,mouseUp);
stage.addEventListener(MouseEvent.MOUSE_UP,mouseUp);
}
private function mouseUp(e:Event):void{
stopDrag();
removeEventListener(MouseEvent.MOUSE_UP,mouseUp);
stage.removeEventListener(MouseEvent.MOUSE_UP,mouseUp);
}
}