questa funzione disegna un rettangolo nello stage regolandone le proprietà, se richiesto
codice:
function drawRect(t:MovieClip, n:String, l:Number, w:Number, h:Number, b:Number, bc:Number, c:Number, o:Object){
t.createEmptyMovieClip(n, l);
with(t[n]){
if(o != undefined){
_x = o._x != undefined ? o._x : 0;
_y = o._y != undefined ? o._y : 0;
_xscale = o._xscale != undefined ? o._xscale : 100;
_yscale = o._yscale != undefined ? o._yscale : 100;
_alpha = o._alpha != undefined ? o._alpha : 100;
_rotation = o._rotation != undefined ? o._rotation : 0;
alphaFill = o.alphaFill != undefined ? o.alphaFill : 100;
} else {
_x = 0;
_y = 0;
_xscale = 100;
_yscale = 100;
_alpha = 100;
_rotation = 0;
alphaFill = 100;
}
lineStyle((b == 0 ? undefined : b), bc);
moveTo(0, 0);
beginFill(c, alphaFill);
lineTo(w, 0);
lineTo(w, h);
lineTo(0, h);
lineTo(0, 0);
endFill();
}
return t[n];
}
esempio di utilizzo:
codice:
var mc = drawRect(this, "prova", 1, 200, 100, 1, 0x000000, 0xFF00000, {_x:100, _y:200, _alpha:50});