By Zevan | December 8, 2008
CLICK HERE TO COPY
Actionscript:
stage.frameRate = 30;
var xp:Number = 0;
var yp:Number = 0;
var counter:Number = 0;
graphics.lineStyle(0,0x999999);
graphics.moveTo(200,200);
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
for (var i:int = 0; i <20; i++) {
counter += .05;
xp=200 + counter * Math.cos(counter);
yp=200 + counter * Math.sin(counter);
graphics.lineTo(xp, yp);
[...]
By Zevan | December 7, 2008
CLICK HERE TO COPY
Actionscript:
Object.prototype.myVar = "I am a variable";
var s:Sprite = new Sprite();
trace(Object(s).myVar);
var v:Video = new Video();
trace(Object(v).myVar);
This.... should not be done... and setting myVar like this:
CLICK HERE TO COPY
Actionscript:
Object(s).myVar = "hello";
Will cause an error....
I keep a folder on my laptop for this website..... when I have a random snippet idea I put it in this [...]
By Zevan | December 6, 2008
CLICK HERE TO COPY
Actionscript:
var xp:Number=Math.random() * stage.stageWidth;
var yp:Number=Math.random() * stage.stageHeight;
graphics.lineStyle(0,0x000000);
graphics.moveTo(xp, yp);
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
xp+=Math.random()*10-5;
yp+=Math.random()*10-5;
graphics.lineTo(xp, yp);
}
Nothing special here, but its good to know that this technique has a name... and that it's NOT Brownian Motion... more here.
By Zevan | December 5, 2008
CLICK HERE TO COPY
Actionscript:
Bitmap(addChild(new Bitmap(new BitmapData(100,100,false,0x000000)))).bitmapData.fillRect(new Rectangle(10,10,10,10), 0xFF0000);