all'interno di un nuovo filmato mettici un bottone con instanza ancora.
ora nel primo frame incolla questo codice
codice:
valore_array = new Array();
function NumRandom(){
totalNum = 6;
rnd = Math.random()*totalNum;
return(parseInt(rnd)+1);
}
function VerificaArray(numeroRand){
for(i=0;i<6;i++){
if(valore_array[i] == numeroRand)
return false;
}
valore_array.push(numeroRand);
return numeroRand;
}
ancora.onPress = function(){
trace(VerificaArray(NumRandom())); //<- restituisce il num che ti interessa
//false se non l'ha trovato
//solo di verifica per vedere cosa c'è nell'array
a = "";
for(i=0;i<6;i++)
a += valore_array[i] + "|" ;
trace(a);
}
ti mostro l'output
codice:
5
5|undefined|undefined|undefined|undefined|undefined|
1
5|1|undefined|undefined|undefined|undefined|
6
5|1|6|undefined|undefined|undefined|
4
5|1|6|4|undefined|undefined|
false
5|1|6|4|undefined|undefined|
false
5|1|6|4|undefined|undefined|
false
5|1|6|4|undefined|undefined|
false
5|1|6|4|undefined|undefined|
3
5|1|6|4|3|undefined|
false
5|1|6|4|3|undefined|
2
5|1|6|4|3|2|
come potrai capire l'ultimo numero è inutile cercarlo perchè logicamente è quello che manca.
se hai problemi chiedi pure
ciao