Yes! There's a method for the Array object; array.remove(Index position). This method RETURNS the value, it doesn't modify the array. Which means you'd have to set a variable, or in this case the cnum array. So I'd right something like:
EDIT: Although this wont make much sense because, I do believe, it would be removing each index on every iteration. So I don't know if you want the last random number in the loop to be the number to remove, if so then change:
Maybe this is just over my head, but the examples do not work for me. The work in the trace window, but remain in the array.
What I want is to define an array in my start script
cnum=new Array(1,2,3,4,5);
have a button with the action
for(i=0;i<cnum.length;i++){
my_edit=random(cnum[i])}
after the button is clicked I need whatever number is in the edit box to be removed fom the array, so when the button is clicked again it can not produce the previous number again.
Ok, it seems that in Flash player exported .swf remove from array is buggy.
Try attached movie in preview and Flash player. In flash player remove is not removing from right position (watch what numbers were in array and what was there after remove)
original way to get the number: (3dfa javascript) my_edit = cnum.remove(random(cnum.length));
and the bug is that above script compiles inside swf to this:
Code:
(Actionscript code, not 3dfa Javascript)
cnum.splice(random(cnum.length), 1);
my_edit = cnum[random(cnum.length)];
Nothing wrong IF you do not use functions that migh return different numbers at different calls
so, use temp variable to store random number and use it as index: (3dfa javascript)