-- welcome to wonderfl --
wonderfl is a service where you can build a Flash online.
write Actionscript3 code in a textarea,
and your code will be compiled server side.
Your compiled Flash will be reloaded automatically
in the right side of the page,
so write code and see it real-time.
Well, why not "FORK" this code and see how it goes?
// forked from mash's wonderfl KeyVisual V.4.en
//
// -- welcome to wonderfl --
//
// wonderfl is a service where you can build a Flash online.
//
// write Actionscript3 code in a textarea,
// and your code will be compiled server side.
//
// Your compiled Flash will be reloaded automatically
// in the right side of the page,
// so write code and see it real-time.
//
// Well, why not "FORK" this code and see how it goes?
//
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.display.BitmapData;
import flash.display.Bitmap;
[SWF(backgroundColor="#FFFFFF", frameRate=10)]
public class FlashTest extends Sprite {
private var canvas:BitmapData;
private var xp:Vector.<int>;
private var yp:Vector.<int>;
private var radius:Vector.<Number>;
private var theta:Vector.<Number>;
private var pixNum:int;
public function FlashTest() {
this.canvas = new BitmapData(200,200,false,0x000000);
this.addChild(new Bitmap(canvas));
scaleX=scaleY=2;
pixNum = canvas.width*canvas.height;
this.xp = new Vector.<int>();
this.yp = new Vector.<int>();
this.radius = new Vector.<Number>();
this.theta = new Vector.<Number>();
for (var i:int = 0; i<pixNum; i++) {
xp.push(i % 200);
yp.push(int(i / 200));
var dx:Number=100-xp[i];
var dy:Number=100-yp[i];
theta.push(Math.atan2(dy, dx));
radius.push(Math.sqrt(dx * dx + dy * dy)/20);
}
addEventListener(Event.ENTER_FRAME, onLoop);
}
private function onLoop(evt:Event):void {
this.canvas.lock();
var n:Number = mouseX / 100;
for (var i:int = 0; i<pixNum; i++) {
var swirl:Number = 1+Math.sin(6*Math.cos(radius[i]) -n*theta[i]);
canvas.setPixel(xp[i], yp[i], Math.abs(255 - swirl * 255));
}
this.canvas.unlock();
}
}
}