This is just a thread where we can post some custom functions that do general stuff for us, nothing stupid but actual useful stuff. Say if we need anything specific, thats all :)
---
function factorial(num:Number):Number {
temp = num;
for (a=1; a<num; a++) {
temp *= a;
}
return temp;
}
Usage:
trace(factorial(4)); //24;
trace(factorial(100)); //9.33262154439442e+157
trace(factorial(6)); //720
---
function drawCircle(X:Number, Y:Number, Radius:Number):Void {
theta = (45/180)*Math.PI;
ctrlRadius = Radius/Math.cos(theta/2);
_root.lineStyle(2, 0, 100);
_root.moveTo(X+Radius, Y);
angle = 0;
for (var i = 0; i<8; i++) {
angle += theta;
var angleMid = angle-(theta/2);
var cx = X+Math.cos(angleMid)*(ctrlRadius);
var cy = Y+Math.sin(angleMid)*(ctrlRadius);
var px = X+Math.cos(angle)*Radius;
var py = Y+Math.sin(angle)*Radius;
_root.curveTo(cx, cy, px, py);
}
}
Usage:
drawCircle(275, 200, 50); //draw a circle AROUND 275, 200 with a diameter of 100
---
function allStats() {
var i:Number = 0;
var sCount:Number = 0;
for (i in _root) {
if (_root[i]._name !== undefined) {
sCount++;
trace("Item "+sCount+": "+_root[i]._name);
trace("Depth: "+_root[i].getDepth());
trace("H. Size: "+_root[i]._xscale);
trace("V. Size: "+_root[i]._yscale);
trace("Height: "+_root[i]._height);
trace("Width: "+_root[i]._width);
trace("_x: "+_root[i]._x);
trace("_y: "+_root[i]._y);
trace(" -----------");
}
}
}
Usage:
allStats(); //Get info on all the objects in your flash
---
function toHex(col:Number):String {
return col.toString(16);
}
Usage:
trace(toHex(16711680)); //ff0000
---
Meh =)
Sup, bitches :)
