6 Replies Latest reply on Apr 27, 2006 2:57 AM by Dilroy

    Play random frames

    Dilroy Level 1
      I am trying to make the movie play random frames when it is opened using the following script:

      gotoAndStop(random(13)+2);

      I managed to do this successfully using numbers in each frame to see where the movie was but then found that when I added content(images and movie clips) to the frames a blank screen (that didn't exist )kept appearing at random intervals and some of the content in certain frames was missing.

      Does anyone know why this is or have an alternative script or method I can use for the randomisation i need?

      p.s I am using Flash 8
        • 1. Re: Play random frames
          kglad Adobe Community Professional & MVP
          if you want to direct the _root timeline to a frame between 2 and 14 use:
          • 2. Re: Play random frames
            Dilroy Level 1
            Thanks I tried that and it's still doing the same thing.

            When you open it up it always goes to the first of the frames that i want randomised(frame2) and an image in this frame is missing. Then when i press the button that points to the first frame so it randomises again everything works ok. It goes randomly through the frames and when the first frame comes up again it contains the missing image.

            Is this a fault in my program do u think?
            • 3. Re: Play random frames
              kglad Adobe Community Professional & MVP
              i'm sure it's a user error. post a link to your fla.
              • 5. Re: Play random frames
                Level 7
                You have to wait until a frame is loaded before you can go to it.

                In the first frame:

                // wait for all frames to load before jumping to random
                this.onEnterFrame = function(){
                if(this._framesloaded == this._totalframes){
                this.onEnterFrame = undefined;
                this.gotoAndStop(random(13)+2);
                }
                }


                Alternatively, you could check if a range of frames is loaded:
                this.onEnterFrame = function(){
                if(this._framesloaded >= aframenumber){...}
                }

                "Dilroy" <webforumsuser@macromedia.com> wrote in message
                news:e2o0s5$l61$1@forums.macromedia.com...
                > I am trying to make the movie play random frames when it is opened using
                the
                > following script:
                >
                > gotoAndStop(random(13)+2);
                >
                > I managed to do this successfully using numbers in each frame to see
                where the
                > movie was but then found that when I added content(images and movie clips)
                to
                > the frames a blank screen (that didn't exist )kept appearing at random
                > intervals and some of the content in certain frames was missing.
                >
                > Does anyone know why this is or have an alternative script or method I
                can use
                > for the randomisation i need?
                >
                > p.s I am using Flash 8
                >
                >


                • 6. Re: Play random frames
                  Dilroy Level 1
                  Nice one Raymond you've solved my problem, it all makes sense now. The randomisation worked with simple numbers in each frame but when there was more content it needed to be told to make sure the content was fully loaded in the frame before going to it. Everything works fine now.

                  Cheers mate you really helped me out of a rut