How can not repeat a random number
hello,
How can not repeat a random number
button code:
PHP Code:
on ( release ) {
var n : int = Math . randomInt ( 20 ) ;
kofa = n ;
MC . loadMovie ( "pic" add n add ".jpg" );
// here i need code
//to disable repeat numbers
// it means if n = 2
// the number 2 dont show again
}
Attached Files
Senior Member
you put the numbers into array [1,22,3,6,8,2,...] and then pop() them one by one, for example.
another way would be something like:
PHP Code:
var had = {};
function uniqueRandom ( n ) {
var r ; do {
r = Math . randomInt ( n );
} while ( had [ r ]);
had [ r ] = true ;
return r ;
}
thanks realMakc
if n=Math.randomInt(800)
how can i generate the array and generate array items randomly
can you write the code, please
Senior Member
Originally Posted by
kofa
can you write the code, please
nope. I know, you said 'please', but I still do not feel like. maybe later.
my final file
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width