Hola Ale:
Yo tengo este invento por acabar desde hace tiempo y no lo he usado nunca.
Es un poco guarro lo del _root mirandolo ahora, pero parece que va bien.
Paulo.
//
// [10/08/02]
/*
sumary: creates and locates a box, with rounded corners if needed
methods :
events :
onDraw() no funciona
examples :
box01 = new RectDraw("box01", 10, 1, 10, 0,85, 100, 305, 0, 0x0000FF, 0,
0xFFFF00);
--> Draws a rounded corner box located at 0x85, 100x305 size, hairline,
blue line color, yellow fill
*/
RectDraw.prototype = new MovieClip();
// RectDraw Class
function RectDraw (nombre, nivel, rounded, roundNum, origenX,origenY, width,
height, gruesoLinea, colorLinea, alfaLinea, colorFondo, alfaFondo)
{
// vars
this.nombre = nombre;
this.nivel = nivel;
this.rounded = rounded;
this.roundNum = roundNum;
this.origenX =origenX;
this.origenY = origenY;
this.width = width;
this.height = height;
this.x1 = 0;
this.y1 = 0;
this.x2 = this.width;
this.y2 = 0;
this.x3 = this.width;
this.y3 = this.height;
this.x4 = 0;
this.y4 = this.height;
this.gruesoLinea = gruesoLinea || 0;// 0 = hairline
this.colorLinea = colorLinea || 0x000000;
this.alfaLinea = alfaLinea < 0 ? 0 : alfaLinea;
this.colorFondo = colorFondo || 0x000000;//0x000000
this.alfaFondo = alfaFondo < 0 ? 0 : alfaFondo;
// creacion
_root.createEmptyMovieClip(this.nombre, this.nivel);
_root[this.nombre]._x = this.origenX;
_root[this.nombre]._y = this.origenY;
if(this.rounded){
with(_root[this.nombre]){
lineStyle( this.gruesoLinea, this.colorLinea, this.alfaLinea );
beginFill( this.colorFondo, this.alfaFondo );
moveTo(this.x1 + this.roundNum,this.y1);
lineTo(this.x2 - this.roundNum,this.y2);
curveTo(this.x2 ,this.y2,this.x2,this.y2 + this.roundNum);
lineTo(this.x3,this.y3 - this.roundNum);
curveTo(this.x3,this.y3,this.x3 - this.roundNum,this.y3);
lineTo(this.x4 + this.roundNum,this.y4);
curveTo(this.x4 ,this.y4,this.x4,this.y4 - this.roundNum);
lineTo(this.x1,this.y1 + this.roundNum);
curveTo(this.x1,this.y1,this.x1 + this.roundNum,this.y1);
// lineTo(this.x1 - 25, this.y1 - 25);
endFill();
}
}else{
with(_root[this.nombre]){
lineStyle( this.gruesoLinea, this.colorLinea, this.alfaLinea );
beginFill( this.colorFondo, this.alfaFondo );
moveTo(this.x1,this.y1);
lineTo(this.x2,this.y2);
// curveTo(95,85,95,100);
lineTo(this.x3,this.y3);
lineTo(this.x4,this.y4);
lineTo(this.x1,this.y1);
endFill();
}
this.onDraw();
}
}// end class
----- Original Message -----
From: "Ale Mu�oz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, November 30, 2003 10:23 PM
Subject: [ASNativos] Problemilla con curveTo()
Jelou...
estoy intentando crear con AS y la Drawing API unos
bonitos rect�ngulos con esquinas redondeadas.
Me encuentro con el problema de que las curvas dibujadas
con curveTo() son *bastante* cutres (quiero decir, que se
ven fatal en pantalla)
Antes de meterme con un m�todo m�s complejo, �alguien ha
conseguido dibujar curvas como dios manda usando curveTo()?
Aqu� est� el prototipo que estoy usando para dibujar los
rect�ngulos, para que veais c�mo salen (y por si me he
equivocado con el c�digo :)
MovieClip.prototype.DrawRoundSquare = function(xpos,ypos,ancho,alto,radius){
this.moveTo(xpos+radius,ypos);
this.lineTo(ancho-radius,ypos);
this.curveTo(ancho,ypos, ancho,ypos+radius);
this.lineTo(ancho,alto-radius);
this.curveTo(ancho,alto,ancho-radius,alto);
this.lineTo(xpos+radius,alto);
this.curveTo(xpos,alto,xpos,alto-radius);
this.lineTo(xpos,ypos+radius);
this.curveTo(xpos,ypos,xpos+radius,ypos);
}
Gracias por adelantado
a!e
<!-------------------------------
Lista ASNativos:
subscripciones/desubscripciones
http://www.sidedev.net/asnativos
-------------------------------->
<!-------------------------------
Lista ASNativos:
subscripciones/desubscripciones
http://www.sidedev.net/asnativos
-------------------------------->