Hi John,
Thank you for your enquiry.
The following script should satisfy both of your requirements:
Code:
function RandomList(number) {
numberlist = new Array();
for (count = 1; count <= number; count++) {
numberlist[count] = count;
}
randomlist = new Array();
for (count = numberlist.length - 1; count > 0; count--) {
picked = Math.floor(Math.random()*count)+1;
randomlist[count-1] = numberlist[picked];
numberlist[picked] = numberlist[count];
}
}
num = 0
function ShowRandom(limit) {
if (num == 0) {
eval("Text" + randomlist[num] + ".Show()")
num++
}
else if (num < limit) {
eval("Text" + randomlist[num-1] + ".Hide()")
eval("Text" + randomlist[num] + ".Show()")
num++
}
else {
eval("Text" + randomlist[num-1] + ".Hide()")
}
}
Please find below a link to download a working demonstration of this script.
To increase the length of the list of random numbers, simply adjust the value of the 'number' parameter which is sent to the RandomList() function (this script action is attached to an On Show trigger on the page).
To limit the number of objects which are shown (as per your second requirement), simply adjust the 'limit' parameter which is sent to the ShowRandom() function (this script action is attached to a Left Mouse Click trigger on the button).
For example, to generate a list of 50 random numbers (or, to be more precise, a shuffled list of the numbers 1 to 50), edit the script action on the page to read the following:
Code:
RandomList(50)
If you only want to show 25 random objects, edit the script action on the button to read the following:
Code:
ShowRandom(25)
I hope this helps. Please do not hesitate to contact me if you have any further queries.
Kind regards,