I'm trying to use a semi-random selector to pick where a graphic will appear in my movie. What I have at the moment is:
ActionScript Code:
string = "1234";
myScrollPane.onEnterFrame = function() {
if (string.length=0) {
string = "1234";
}
index = random(string.length);
trace(index+" returns "+string.substring(index, index+1));
}
This returns a number from one to four, which is what it's supposed to do but as it stands it's just a verbose version of
What I want to do is have numbers removed from the string as they're retrieved. To that end I included the "if (string.length = 0)" to repopulate the list. With both of those working I should have a random number generator which will not repeat any number until every number in the list has been used.
My problem is that none of the string operators actually seem to alter the string- slice, charAt and substring all return values while leaving the string untouched. Is there a way to do this with a string, or should I be using something like an array?