I’m making a slideshow that plays the different slides at random. I have a movieclip named products that will have a different image on each of the 19 frames, and a code on the main timeline that changes the frames of the movie clip.
I’m having a little issue with this code.
At first I used:
_root.products.gotoAndStop(random(19));
But I kept having one image show up two and sometimes three times in a row. So I tried making something up myself that went like this:
//Declaring my variables frm(Frame) and rfrm(Random Frame)
var frm:Number = 0;
var rfrm:Number = 0;
var rfrm2:Number = 0;
//giving the frames their values.
frm = _root.products.currentframe;
rfrm = (random(19));
rfrm2 = (random(19));
//Make the random frame not be the same as the last one.
if (frm=rfrm) {
rfrm = (random(19));
_root.products.gotoAndPlay("na");
} else {
_root.products.gotoAndStop(rfrm);
}
//asign new values to variables
frm = _root.products.currentframe;
rfrm = (random(19));
I know it’s not perfect by any means, and it still gets the same image twice in a row sometimes, but never three.
Can can I improve this? I know that this is more of a logic problem than actually knowing the right code. I just can’t think of the solution. :upset: