Hi everyone last time I left you I was working on having a slide show that jumps to random frames labels well I got that taken care off:
function getRandomLabel():String
{
var labels:Array = new Array("a","b","c");
var index:Number = Math.floor(Math.random() * labels.length);
return labels[index];
}
this.gotoAndPlay(getRandomLabel());
But the plot thickens, now I’m trying to get the abvoid playing the same frame lable 2 times in a row. Here is the code I currently have:
var labels:Array = new Array("a","b","c","d","e","f");
var index:Number = Math.floor(Math.random() * labels.length);
var currentRandomLabel:String;
var newRandomLabel:String;
function getRandomLabel():String
{
return labels[index];
}
function nextRandomFrame():void
{
getRandomLabel();
trace("Current random label: " + currentRandomLabel);
if(currentRandomLabel != newRandomLabel)
{
currentRandomLabel = newRandomLabel;
trace("New Random Label: " + newRandomLabel);
this.gotoAndPlay(getRandomLabel());
}
else
{
trace("I'm trying to find a new frame label!");
nextRandomFrame();
}
}
Now I’m looking this code over and to me it looks like it should be working. I simply have added a
var currentRandomLabel:String;
var newRandomLabel:String;
To the code and then compair them in a conditonal. What is actully happening is when I publish my movie it simply plays throught the time line linearly going from A to F in normal order.
If any one feels like looking over the FLA plz feel free to DL it at this link:
http://www.johncliffordtaylor.com/test/random_frame.fla
or
http://www.johncliffordtaylor.com/test/random_frame.rar
Thank you for all your help
JT