Skip to main content
Participant
March 11, 2013
Answered

Random frame

  • March 11, 2013
  • 2 replies
  • 507 views

I have a slideshow setup to load on a random frame using this:

function onEnter(evt){

          if(loaderInfo.bytesLoaded == loaderInfo.bytesTotal){

                    visible = true;

                    gotoAndPlay(int(Math.random()*totalFrames)+1);

                    removeEventListener('enterFrame',onEnter);

                    stop();

          }

There are 16 frames, yet I want it to only load a random frame from the first 8. What do I need to change with gotoAndPlay to make it only choose a random frame from the first 8?

Thanks

This topic has been closed for replies.
Correct answer Ned Murphy

Just replace totalFrames with the value 8.  If you are certain totalFrames will always be 16 you could use totalFrames/2

2 replies

kglad
Community Expert
Community Expert
March 12, 2013

(and, get rid of that stop() if you really want the timeline to play.)

Ned Murphy
Ned MurphyCorrect answer
Legend
March 11, 2013

Just replace totalFrames with the value 8.  If you are certain totalFrames will always be 16 you could use totalFrames/2