hunger 0 Denunciar post Postado Outubro 15, 2007 Fala pessoal! Estou desenvolvendo um quiz, onde cada sessão possui 5 questões (de 96 cadastradas). Está randomizado...mas mesmo com 96 questões, aconteceu de repetir uma mesma pergunta em uma única sessão. Como eu faria então para inserir um comando onde, com a randomização, evite repetir pergunta? O código original não foi feito por mim, apenas algumas alterações. Mas não tenho mesmo idéia de como fazer esse "bloqueio"... preciso de uma luz! http://forum.imasters.com.br/public/style_emoticons/default/upset.gif A action está assim: // Random generation QuestionsObject.prototype.nextAnswer = function(){ ranQuestion = random(domande.length) for(var i = 0; i < domande.length; i++){ if(ranQuestion == tempArray[i]){ var prosegui = false; nextAnswer(); break; } var prosegui = true; } if(prosegui){ tempArray.push(ranQuestion); return ranQuestion; }}// Remove the old pointsObject.prototype.removePoints = function(what,keep){ for(var clips in _root.box){ if(_root.box[clips]._name.substring(0,_root.box[clips]._name.length -1) == what.substring(0,what.length-1) && _root.box[clips] != _root.box[what]){ _root.box[clips].point._visible = 0 } }}// remove old answersObject.prototype.removeAllAnswer = function(){ for(var answer in _root.box){ removeMovieClip(_root.box[answer]) }}// Build the QuestionObject.prototype.buildQuestion = function() { creaNuovoArray(); countAnswer++; delete myChoice; // call function to generate a random unique question nextAnswer(); numero_domanda = "Questão " + countAnswer; // current Question domanda = (domande[ranQuestion][0]) // Assing Question txt removeAllAnswer(); // build answers; for(var i = 0; i < domande[ranQuestion][2].length; i++){ nextRisposta(); duplicateMovieClip("box.answer","answer"+i,i) box["answer"+i].y_fin = answer0._y + (40*i) box["answer"+i].txt = domande[ranQuestion][2][ranAns] if(ranAns == domande[ranQuestion][1]){ box["answer"+i].thisChoice = true } else { box["answer"+i].thisChoice = false } } box.answer._visible = 0}// Building random answersfunction creaNuovoArray(){ delete tempRis; tempRis = new Array();}Object.prototype.nextRisposta = function(){ ranAns = random(domande[ranQuestion][2].length) for(var i = 0; i < domande[ranQuestion][2].length; i++){ if(ranAns == tempRis[i]){ var prosegui = false; nextRisposta(); break; } var prosegui = true; } if(prosegui){ tempRis.push(ranAns); return ranAns; }} Se alguém quiser analisar pelo FLA, está no endereço: www.lacerta.com.br/quiz/quiz8.fla Vou tentando por aqui, tem até um outro tópico meu dando dor de cabeça pra vocês! http://forum.imasters.com.br/public/style_emoticons/default/assobiando.gif Abço! Marcos Hunger. Compartilhar este post Link para o post Compartilhar em outros sites
sanamaria 0 Denunciar post Postado Outubro 16, 2007 armazena num array os numeros já sorteadose a cada novo sorteiofaz um for no array comparando o novo numero sorteado,se ele já existe, sorteia denovo, se não armazena ele no array ;) Compartilhar este post Link para o post Compartilhar em outros sites