Código :
/**************************************************************/ stop (); var buenas = 0; //Contador de las buenas var malas = 0; //Contador de las malas var ignorancia_x = 28; var ignorancia_y = 90; var camello_x = 36; var camello_y = 140; var avanza = 38; var kilometros=1; //Se lee del XML var numPreguntas=0; //Se lee del XML var correcto = 0; //Se lee del XML var META=10; //Km para finalizar var todasLasPreguntas = new Array(); //Vector para guardar las preguntas del XML /**************************************************************/ var aimlXML = new XML(); //Objeto XML aimlXML.load("preguntas.xml"); //Lee archivo XML aimlXML.onLoad = loadedXML; //Al terminar, ejecuta funcion /**************************************************************/ function pregunta(p1, p2, p3, p4, p5, p6, p7){ this.numero = p1; //Numero de pregunta this.texto = p2; //Texto de la pregunta this.op1 = p3; //Opcion 1 this.op2 = p4; //Opcion 2 this.op3 = p5; //Opcion 3 this.correcto = p6; //Opcion correcta this.kilometros = p7; //Valor de la pregunta en KM this.ya = 0; //0 no ha sido preguntado, 1 ya fue preguntada } /**************************************************************/ function loadedXML(){ allText = aimlXML.firstChild; //Lee todo el archivo a = allText.firstChild; //Lee el primer nodo arrayPreguntas = allText.childNodes;//Hace el array de preguntas numPreguntas = arrayPreguntas.length;//Evalua el no de preg. en el archivo for (var i=0;i<numPreguntas;i++){ laPregunta = a.childNodes; //Genera Vector y vacia variables num = parseInt(laPregunta[0].firstChild.toString()); tex = laPregunta[1].firstChild.toString(); op1 = laPregunta[2].firstChild.toString(); op2 = laPregunta[3].firstChild.toString(); op3 = laPregunta[4].firstChild.toString(); ok = laPregunta[5].firstChild.toString() km = parseInt(laPregunta[6].firstChild.toString()); todasLasPreguntas[i] = new pregunta(num, tex, op1, op2, op3, ok, km); a = a.nextSibling; //Lee Proximo nodo } } /**************************************************************/ function buscaPregunta(buscaPregunta){ myPregunta = todasLasPreguntas[buscaPregunta].texto; opcion1 = todasLasPreguntas[buscaPregunta].op1; opcion2 = todasLasPreguntas[buscaPregunta].op2; opcion3 = todasLasPreguntas[buscaPregunta].op3; correcto = todasLasPreguntas[buscaPregunta].correcto; kilometros = todasLasPreguntas[buscaPregunta].kilometros; } /**************************************************************/ function evalua(respuesta){ if (correcto==respuesta){ //Evalua respuesta buenas++; //Incrementa variable } else { malas++; //Incrementa malas } if (buenas>=META){ winner="Ganaste!"; //Ya gano :) gotoAndPlay (2); } if (malas>=META){ winner="Lo siento, perdiste"; //Ya perdio :( gotoAndPlay (2); } proximaPregunta(); //La que sigue } /**************************************************************/ function proximaPregunta(){ do { iPregunta=random(numPreguntas); //Busca pregunta nuevecita } while (todasLasPreguntas[iPregunta].ya==1); todasLasPreguntas[iPregunta].ya=1; //La marca como ya hecha buscaPregunta(iPregunta); //Busca pregunta avanza_ignorancia(malas); //Dibuja Ignorancia avanza_camello(buenas); //Dibuja su ficha } /**************************************************************/ function avanza_ignorancia (malas) { setProperty ("_root.ignorancia", _x, ignorancia_x + avanza * malas); setProperty ("_root.ignorancia", _y, ignorancia_y); myMalas = malas; } /**************************************************************/ function avanza_camello (buenas) { setProperty ("_root.camel", _x, camello_x + avanza * buenas); setProperty ("_root.camel", _y, camello_y); myBuenas = buenas; } /**************************************************************/
Resulta que al ejecutarlo funciona x una pregunta y luego se detiene, se cuelga, y sale la pantallita para anular script, alguien sabe que se debe cambiar al codigo o a algo...
Espero la respuesta gracias.