Loop Random Frame Labels
Hello. I recently got a code from David Stiller's blog that I really like. It's about how to get a series of frame labels to play in random order without ever repeating. That's awesome, and I understand most of the code.
However, when all the frame labels have been 'played', I don't want it to just go and rest/stop on the last frame. I want it to start the process all over again. Is there a way to do this? Here is the code I currently have:
function shuffle(arr:Array):Void {
var len:Number = arr.length - 1;
for (var i:Number = len; i >= 0; i--) {
var p:Number = Math.floor(Math.random() * (i + 1));
var t:Object = arr;
arr = arr
;
arr
= t;
}
}
var labels:Array = ["a", "b", "c", "d", "e"];
shuffle(labels);
var currentLabel:Number = 0;
function gotoNextLabel():Void {
if (currentLabel < labels.length) {
gotoAndPlay(labels[currentLabel]);
currentLabel++;
} else {
stop();
}
}
gotoNextLabel();
Here is the blog entry I got it from: http://www.quip.net/blog/2007/flash/how-to-jump-randomly-to-frame-labels-without-repeatshttp://
I'm guessing I have to replace 'stop' toward the end with something else, but what? Repeat?
