Para aclarar, quizá un poco más, en la biblioteca tengo el mc (que es el cuadradito que se reproduce exportado con el nombre "Boton") . La solución estaría, a mi parecer, en generar otro mc con otro nombre de exportación y obviamente otro color. El punto está en que no se como resolver ésto dentro del código.
A continuación tengo en la 1º capa del primer fotograma este código:
Código :
MovieClip.prototype.comportamiento = function () {
//
this.numero = this.campoTexto.text;
//
if (this.numero > botonesPorFila) {
this._y = _root["boton" + (this.numero - 1)]._y + _root["boton" + (this.numero - 1)]._height + separacionY;
} else {
boton._y = posInicialY;
}
this.posIniY = this._y;
//
this.onEnterFrame = function () {
//
// No uso rollOver y rollOut porque falla si la aplicación pierde foco con un boton seleccionado
if (this.hitTest (_xmouse, _ymouse)) {
this.seleccionado = true;
} else {
this.seleccionado = false;
}
this.bordeNegro._visible = this.seleccionado;
this.bordeGris._visible = !this.seleccionado;
//
if (this.numero > botonesPorFila) {
this._y = _root["boton" + (this.numero - 1)]._y + _root["boton" + (this.numero - 1)]._height + separacionY;
if (_root["boton" + (this.numero - 1)].posIniY != _root["boton" + (this.numero - 1)]._y && _root["boton" + (this.numero - 1)]._y > this._y) {
if (this.numero != 2) {
this._y = _root["boton" + (this.numero - 1)]._y;
}
}
}
//
// En caso de agregar una cuarta fila, hay que ubicar este código dentro del if:
// || this.numero == 31
// Siguiendo esta misma lógica, debe haber un elemento del if por cada fila.
if (this.numero == 1 || this.numero == 2 || this.numero == 3 || this.numero ==4 || this.numero ==5 || this.numero ==6) {
this._x = posInicialX;
} else {
this._x = _root["boton" + (this.numero - 1)]._x + _root["boton" + (this.numero - 1)]._width + separacionX;
}
//
// Agrandamos y achicamos los botones
if (this.seleccionado && this._xscale < maxSize) {
this._xscale = this._yscale += (maxSize - this._xscale) / 5;
}
if (!this.seleccionado && this._xscale > 100) {
this._xscale = this._yscale -= (maxSize - this._xscale) / 2;
}
//
// Evitamos que los botones se achiquen o agranden en exceso
if (this._xscale < 100) {
this._xscale = this._yscale = 100;
}
if (this._xscale > maxSize) {
this._xscale = this._yscale = maxSize;
}
};
};
y en el 1º fotograma de la 2º capa este código:
Código :
//
var numeroBotones:Number =6;
//
var posInicialX:Number = 300, posInicialY:Number = 90;
var separacionX:Number = 10, separacionY:Number = 30;
//
var botonesPorFila:Number = 1, numeroFilas:Number = Math.ceil (numeroBotones / botonesPorFila);
//
var maxSize:Number = 1000;
//
for (i = 1; i <= numeroBotones; i++) {
//
this.attachMovie ("Boton", "boton" + i, i);
var boton = _root["boton" + i];
//
boton.campoTexto.text = i;
//
boton.comportamiento ();
}
Gracias.
