flash on 2012-9-21
/**
* Copyright mwelsh ( http://wonderfl.net/user/mwelsh )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/4y3s
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Rectangle;
import flash.utils.getTimer;
public class FlashTest extends Sprite {
public function FlashTest() {
addEventListener(Event.ENTER_FRAME, onEnterFrame);
bData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xff000000);
addChild(new Bitmap(bData));
rect = new Rectangle();
stage.frameRate = 60;
}
private var bData:BitmapData;
private var rect:Rectangle;
private var t : Number = 0;
private var vt : Number = 0;
private function onEnterFrame(event : Event):void {
bData.fillRect(bData.rect, 0xff000000);
t += vt;
vt = Math.sin(getTimer()/1000) * 0.1;
var theta:Number = t;
const r : Number = 0.5;
var x0 : Number;
var x1 : Number;
var x2 : Number;
var x3 : Number;
var cos : Number;
var sin : Number;
rect.height = 1;
for(var i:uint=0; i<stage.stageHeight; i++) {
cos = Math.cos(theta);
sin = Math.sin(theta);
x0 = (r*cos+1)*stage.stageWidth*0.5;
x1 = (r*sin+1)*stage.stageWidth*0.5;
x2 = (-r*cos+1)*stage.stageWidth*0.5;
x3 = (-r*sin+1)*stage.stageWidth*0.5;
rect.y = i;
if(x0<x1) {
rect.x = x0;
rect.width = x1-x0;
bData.fillRect(rect, uint((cos*0.5+0.5)*0x88 + 0x55) << 16 | 0xff000000);
}
if(x1<x2) {
rect.x = x1;
rect.width = x2-x1;
bData.fillRect(rect, uint((sin*0.5+0.5)*0x88 + 0x55) << 8 | 0xff000000);
}
if(x2<x3) {
rect.x = x2;
rect.width = x3-x2;
bData.fillRect(rect, uint((-cos*0.5+0.5)*0x88 + 0x55) | 0xff000000);
}
if(x3<x0) {
rect.x = x3;
rect.width = x0-x3;
var n:int = uint((-sin*0.5+0.5)*0x88 + 0x55);
bData.fillRect(rect, n<<16 | n<<8 | 0xff000000);
}
vt = Math.sin(getTimer()/1000) * 0.03;
theta += vt;
}
}
}
}