Código PHP:
//Defino el ancho del trazo inicial
var ancho_trazo:Number = 5;
//Esta función será invocada al hacer click para dibujar
function dibujar() {
panelDibujo.moveTo(panelDibujo._xmouse,panelDibujo._ymouse);
panelDibujo.onMouseMove = function() {
this.lineStyle(ancho_trazo,color_trazo,100);
this.lineTo(panelDibujo._xmouse,panelDibujo._ymouse);
updateAfterEvent();
};
panelDibujo.onMouseUp = function() {
delete this.onMouseMove;
};
}
//Al hacer click invocamos la función dibujar
panelDibujo.onMouseDown = dibujar;
/*--------------------------------------*/
//Función genérica para crear los botones
function crearboton(nombre, profundidad, x, y) {
var btn = this.createEmptyMovieClip(nombre, profundidad);
btn.lineStyle(ancho_boton,color_boton,100);
btn.moveTo(0,0);
btn.lineTo(0.2,0);
btn._x = x;
btn._y = y;
}
/*-----------------------*/
//Aqui vamos creando los botones especificando sus parámetros
crearboton("negro",1,63,316,ancho_boton=15,color_boton=0x000000);
crearboton("gris",2,83,316,ancho_boton=15,color_boton=0xCCCCCC);
crearboton("rojo",3,103,316,ancho_boton=15,color_boton=0xFF0000);
crearboton("azul",4,123,316,ancho_boton=15,color_boton=0x0000FF);
crearboton("verde",5,143,316,ancho_boton=15,color_boton=0x33CC00);
//-----------------------//
crearboton("ancho_1",6,23,55,ancho_boton=5,10,color_boton=0x000000);
crearboton("ancho_2",7,23,75,ancho_boton=9,10,color_boton=0x000000);
crearboton("ancho_3",8,23,90,ancho_boton=12,10,color_boton=0x000000);
crearboton("ancho_4",9,23,110,ancho_boton=15,10,color_boton=0x000000);
/*----------------------*/
//Aqui van las acciones al presionar los botones
/*--Colores--*/
rojo.onRelease = function() {
color_trazo = 0xFF0000;
};
azul.onRelease = function() {
color_trazo = 0x0000FF;
};
verde.onRelease = function() {
color_trazo = 0x33CC00;
};
negro.onRelease = function() {
color_trazo = 0x000000;
};
gris.onRelease = function() {
color_trazo = 0xCCCCCC;
};
/*---Trazos---*/
ancho_1.onRelease = function() {
ancho_trazo = 5;
};
ancho_2.onRelease = function() {
ancho_trazo = 9;
};
ancho_3.onRelease = function() {
ancho_trazo = 12;
};
ancho_4.onRelease = function() {
ancho_trazo = 20;
};