Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

square.as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
_global.square = function(mc, x,y, w,h, centered, lstyle, fstyle){
	if (!centered){
		w /= 2; h /= 2;
		x += w; y += h;
	}
	// lstyle and fstyle are arrays of lineStyle and beginFill arguments respectively
	if (lstyle) mc.lineStyle.apply(mc, lstyle);
	if (fstyle) mc.beginFill.apply(mc, fstyle);
	mc.moveTo(x-w, y-h);
	mc.lineTo(x+w, y-h);
	mc.lineTo(x+w, y+h);
	mc.lineTo(x-w, y+h);
	mc.lineTo(x-w, y-h);
	if (fstyle) mc.endFill();
	return mc;
};