I am running a movie which should start at a random position and follows with a random sequence. The action is placed in frame 1 and all content starts from frame 2. The randomizing works, but only after it plays through "a" frames. For example, it will play a, k e i a f g b j d h c, then continues to randomize the labels. The source of this code was from http://www.quip.net/blog/2007/flash/...ithout-repeats. I'm sure there is something small I am missing, I am new to actionscript. Thanks for any help on making sure this starts in a random position.
Code: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[i]; arr[i] = arr[p]; arr[p] = t; } } var labels:Array = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "k"]; shuffle(labels); var currentLabel:Number = 0; function gotoNextLabel():Void { if (currentLabel < labels.length) { gotoAndPlay(labels[currentLabel]); currentLabel++; } else { shuffle(labels); currentLabel = 0; gotoAndPlay(labels[currentLabel]); currentLabel++; } } gotoNextLabel();




Bookmarks