Mi problema es el siguiente: tengo varios fotogramas con ejercicios distintos y debo en un limite de tiempo mostrar estos ejercicios...cada frame manda llamar una funcion "carga" que dependiendo el nombre del movieclip le agrega eventos y propiedades, cada que un ejercicio se contesta se manda llamar otro y se repite la carga se trata de ver quien hace mas ejercicios, el problema es que en ciertas ocasiones me lanza el clasico error #1009 acceso a un objeto o propiedad nula
Código :
public function carga() {
inicio_arreglos();
var nombre:String=new String();
var short_name:String=new String();
for (var i=0; i<this.numChildren; i++) {
nombre=this.getChildAt(i).name;
if (nombre.indexOf("a")==0) {
trace("nombre: "+nombre);
var obj=this.getChildAt(i);
var punto:Point=new Point(obj.x,obj.y);
short_name=nombre.substring(nombre.indexOf("_"));
obj.addEventListener(MouseEvent.MOUSE_DOWN,arrastrar);
obj.addEventListener(MouseEvent.MOUSE_UP,soltar);
obj.destino=Number(short_name.substring(short_name.indexOf("_")+1));
trace("destino: "+obj.destino);
coordenadas[Number(nombre.substring(1,nombre.indexOf("_")))]=punto;
if(obj.visible==false){
obj.visible=true;
}
origenes_array.push(obj);
}else if (nombre.indexOf("d")==0 ) {
trace("nombre: "+nombre);
var obj2;
var pos:Point;
short_name=nombre.substring(nombre.indexOf("_"));
obj2=this.getChildAt(i);
obj2.destino=Number(short_name.substring(short_name.indexOf("_")+1));
pos=new Point(obj2.x,obj2.y);
trace("destino: "+obj2.destino);
obj2.unico=false;
obj2.addChild(crearContenedor(obj2));
pos=obj2.getChildAt(obj2.numChildren-1).globalToLocal(pos);
obj2.getChildAt(obj2.numChildren-1).x=pos.x;
obj2.getChildAt(obj2.numChildren-1).y=pos.y;
destino_array.push(obj2);
}
else if (nombre.indexOf("c")==0) {
obj;
obj=this.getChildAt(i);
short_name=nombre.substring(nombre.indexOf("_"));
obj.addEventListener(MouseEvent.CLICK,click_origen);
obj.destino=Number(short_name.substring(short_name.indexOf("_")+1));
origenes_array.push(obj);
}
}
}
////////////////////////////////////Usualmente el error aparece en esta linea "nombre=this.getChildAt(i).name;" pero tmb llega aparecer lineas mas abajo.
Segundo espero no sea abuso de confianza.....ciertos movieclips son arrastrables , uso lo mas sencillo startDrag(); el problema esque cualquier movieclip que se arrastre al cambio de frame sigue viendose en pantalla, no entiendo por que si no pertenece a ese frame.
De antemano gracias por su ayuda...
