Randomized Triangle
♥0 |
Line 42 |
Modified 2010-02-15 17:17:31 |
MIT License
archived:2017-03-20 14:44:10
ActionScript3 source code
/**
* Copyright deform ( http://wonderfl.net/user/deform )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/aM3h
*/
package {
import flash.display.ShaderParameter;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.*;
import flash.utils.Timer;
public class FlashTest extends Sprite {
private var shape:Sprite;
private var shapecontainer:Sprite;
private var t:Timer;
public function FlashTest() {
// write as3 code here.
shapecontainer = new Sprite();
shape = new Sprite();
addChild(shapecontainer);
shapecontainer.addChild(shape);
shapecontainer.x = stage.stageWidth/2;
shapecontainer.y = stage.stageHeight/2;
t = new Timer(100);
t.start();
t.addEventListener(TimerEvent.TIMER, _upDate);
addEventListener(Event.ENTER_FRAME, _timerSet);
}
private function draw():void
{
shape.graphics.clear();
shape.graphics.beginFill(0x0);
shape.graphics.moveTo(0,0);
shape.graphics.lineTo(Math.random()*100, Math.random()*100);
shape.graphics.lineTo(Math.random()*30, Math.random()*150);
shape.graphics.endFill();
shape.x = -shape.width/2;
shape.y = -shape.height/2;
}
private function _timerSet(e:Event):void{
t.delay = Math.random()*80;
}
private function _upDate(e:Event):void{
draw();
shapecontainer.rotation = Math.random()*180;
}
}
}