Código :
class Cuadrado extends MovieClip {
//DECLARO TODAS LAS VARIABLES COMO PUBLICAS
//...
//CONSTRUCTOR
function Cuadrado() {
//SI ES EL PRIMER CLIP
if (this._name == "x0y0") {
//LO UBICAMOS EN UN LUGAR PREDEFINIDO
this._x = 100;
this._y = 100;
//SUS VARIABLES nx Y ny SON CERO
this.NX = 0;
this.NY = 0;
}
//AHORA ESTO PARA TODOS LOS CLIPS QUE SE CREEN
//ESTAS VARIABLES SIRVEN PARA REFERENCIAR LOS CLIPS ALEDAÑOS
this.arriba = this.NY+1;
//AL CREARSE SE SETEA LA VARIABLE AVAIBLE PARA QUE OTROS PUEDAN COMPROBAR SI EXISTE
this.avaible = true;
}
public function comprobar():Void {
//DEFINIMOS EL NOMBRE DEL CLIP QUE DEBERIA ESTAR ARRIBA (EN EL CASO DEL PRIMER CLIP, EL DE ARRIBA SERIA x0y1
this.destino = "x"+NX+"y"+arriba;
//SI NO EXISTE LA VARIABLE AVAIBLE EN EL CLIP DESTINO, ES PORQUE EL CLIP DESTINO NO EXISTE
if (_root[destino].avaible == undefined) {
//ENTONCES LO CREAMOS
attachMovie("cuadrado",destino,_level0.getNextHighestDepth,{_y:-100, NX:this.NX, NY:arriba});
}
}
private function onEnterFrame() {
//HACEMOS LA COMPROBACION TODO EL TIEMPO
comprobar();
}
}ahora esto en teoria funciona bien, ya que se crean infinitamente clips 100 pixeles arriba del anterior, haciendo una cadena. el problema es cuando quiero empezar a hacer las funciones para abajo y para los costados:
lo primero que hago es crear un valor para el nombre que tendria el clip inferior
Código :
//AHORA ESTO PARA TODOS LOS CLIPS QUE SE CREEN //ESTAS VARIABLES SIRVEN PARA REFERENCIAR LOS CLIPS ALEDAÑOS this.arriba = this.NY+1; this.abajo = this.NY-1;
luego copio la funcion para comprobar el clip de arriba pero le cambio los datos para el clip inferior
Código :
//ESTA FUNCION ES IGUAL, PERO PARA COMPROBAR LA EXISTENCIA DEL CLIP INFERIOR
this.destino = "x"+NX+"y"+abajo;
if (_root[destino].avaible == undefined) {
attachMovie("cuadrado",destino,_level0.getNextHighestDepth,{_y:+100, NX:this.NX, NY:abajo});
}aqui empiezan los problemas, porque ya no se crean clips ni para arriba ni para abajo, sino que se crean todos en la misma posicion: por debajo del original y todos encimados infinitamente
estoy casi segurisimo de que el problema es el pathing en el IF, ya que he hecho un trace:
Código :
//ESTA FUNCION ES IGUAL PARA EL CLIP DE ABAJO
this.destino = "x"+NX+"y"+abajo;
if (_root[destino].avaible == undefined) {
trace(_root[destino].avaible);
attachMovie("cuadrador",destino,_level0.getNextHighestDepth,{_y:+100, NX:this.NX, NY:abajo});
}y siempre me tira undefined, es decir que se estan haciendo mal las comprobaciones de si existen o no clips arriba y abajo
la pregunta es, estoy en lo correcto con respecto a mi error?
si fuera asi, me pueden recomendar algun buen tutorial de pathing (rutas) en flash?
