Código :
clase{
variables
constructor{
evento onRelease{}
evento onRollOver{}
evento onRollOut{}
}
}digamos que lo ques estoy haciendo es una clase que mejora los botones que por defecto que permite hacer el IDE de flash. En este caso se hace a travez de mc\\\'s.
la clase identifica 3 metodos:
onRelease, oRollOver, onRollOut.
La mejora es que identifica el fin de onRollOver y el fin de onRollOut (lo cual sirve para efectos de animacion, por ejemplo: que la animacion que ocurre entre el estado \\\"Encima\\\" y \\\"Presionado\\\" sea fluida y no cambie bruscamente la animacion).
Ademas identifica que boton ha sido presionado y cual ha quedado sin presionar, habilitandolo y deshabilitandolo respectivamente.
No es algo que no se haya hecho antes.
De que forma la ejecuto:
var miVar:claseBoton = new claseBoton(nombreDelBoton:MovieClip,onRollOverEnd:Number;onRollOutEnd:Number); <---todo esto se hace para cada boton, donde si por ejemplo los botones son duplicados, lo unico que cambiaria serian el \\\"nombre del boton\\\".
en donde onRollOverEnd, onRollOutEnd son los numeros respectivos de las etiquetas en donde sus estados terminan (sus obvios estados onRollOver y onRollOut) esto por el hecho de que en AS2 no se puede determinar el currenFrame de un nombre de etiqueta.
ejemplo de ejecucion:
var miVar:claseBoton = new claseBoton(boton1:MovieClip,12:Number;20:Number);
var miVar2:claseBoton = new claseBoton(boton2:MovieClip,12:Number;20:Number);
var miVar3:claseBoton = new claseBoton(boton3:MovieClip,12:Number;20:Number);
EL PROBLEMA:
problablemente mi logica.....
supongo al ser objetos diferentes, las variables no son las mismas, y por tanto no se conectan...
me refiero especificamente a una variable llamada \\\"deselecion\\\" que identifica que boton ha dejado de ser presionado...
bueno aqui va el codigo:
Código :
class botonMaestro {
//Se usa: var miVar:botonMaestro = new botonMaestro(nombreDelBoton:MovieClip, rollOverEnd:Number, rollOutEnd:Number);
/* DECLARACION DE VARIABLES */
var rollOverEnd:Number;
var rollOutEnd:Number;
var Colision:Boolean;
var deseleccionado:MovieClip;
/* CONSTRUCTOR
En esta funcion se asignan los eventos y propiedades del boton */
function botonMaestro(nombreDelBoton:MovieClip, rollOverEnd:Number, rollOutEnd:Number) {
trace(\"El constructor de botonMaestro se ha ejecutado !!\");
//se hace invisible al zona activa
nombreDelBoton.hitMc._alpha = 0;
_global.seleccionado;
//EVENTO: onRollOver
nombreDelBoton.hitMc.onRollOver = function() {
trace(\"El evento onRollOver de botonMaestro se ha ejecutado !!\");
trace(\"this: \"+this);
this._parent.gotoAndPlay(\"rollOver\");
this._parent.onEnterFrame = function() {
//this=_level0.miBoton_suit
//trace(\"onEnterFrame !!\");
trace(\"currentframe: \"+this._currentFrame);
if (this._currentFrame == rollOverEnd) {
this.stop();
trace(\"rollOverEnd\");
delete this.onEnterFrame;
}
};
};//termina evento \"onRollOver\"
//EVENTO: onRollOut
nombreDelBoton.hitMc.onRollOut = function() {
trace(\"El evento onRollOut de botonMaestro se ha ejecutado !!\");
trace(\"this: \"+this);
//trace(\"seleccionado: \"+seleccionado);
this._parent.gotoAndPlay(\"rollOut\");
this._parent.onEnterFrame = function() {
//this=_level0.miBoton_suit
//trace(\"onEnterFrame !!\");
trace(\"currentframe: \"+this._currentFrame);
if (this._currentFrame == rollOutEnd) {
this.stop();
trace(\"rollOutEnd\");
delete this.onEnterFrame;
}
};
};//termina evento \"onRollOut\"
//EVENTO: onRelease
nombreDelBoton.hitMc.onRelease = function() {
trace(\"\\n\");
trace(\"released\");
deseleccionado = seleccionado;
seleccionado = this._parent;
trace(\"DESseleccion: \"+deseleccionado);
trace(\"seleccion: \"+seleccionado);
//se deshabilita la zona activa(hitMc)
this.enabled = false;
//1.- carga inmediatamente la animacion
//this.gotoAndStop(\"seleccionado\");
//2.- Se espera hasta que rollOver termine para ejecutar la animacion
this._parent.onEnterFrame = function() {
trace(\"onEnterFrame !!\");
//this=_level0.miBoton_suit
trace(\"currentframe: \"+this._currentFrame);
if (this._currentFrame == rollOverEnd) {
this.gotoAndStop(\"seleccionado\");
delete this.onEnterFrame;
}
//end if
};
this._parent._parent[\"deseleccionado\"].hitMc.enabled = true;
this._parent._parent[\"deseleccionado\"].gotoAndPlay(\"rollOut\");
this._parent._parent[\"deseleccionado\"].onEnterFrame = function() {
trace(\"onEnterFrame !!\");
trace(\"currentframe: \"+this._currentFrame);
if (this._currentFrame == rollOutEnd) {
this.stop();
trace(\"rollOutEnd\");
delete this.onEnterFrame;
}
//end if
};
};//termina evento \"onRelease\"
}//cierra constructor \"botonMaestro\"
//metodo de la clase
function metododo1() {
trace(\"metodo1 se ha ejecutado !!\");
}
}//termina botonMaestro 