2 Replies Latest reply on Jul 18, 2006 5:07 AM by Newsgroup_User

    randomly loading images that don't reapeat

    mlamaudite
      I am making a slideshow that randomly loads jpegs in a mc on the stage. I am trying to find a way to prevent flash to load the same image twice in a row.
      Can anyone help me please?

      Thanks!!
        • 1. Re: randomly loading images that don't reapeat
          Level 7
          Hi,

          I guess you are using sone kind if id for the images...

          // --------------------------------------------------------------------

          // 1. set current id (nCurrentId) of the image just played as previous id
          (nPreviousId)
          // 2. pick a new current id in random

          if (nCurrentId == nPreviousId) {

          // image is the same as before. do the following:

          // try to play one after the selected, unless is is the over the total
          images, play the first one
          if (nCurrentId+1 > nTotalImages) { // we went over the available images
          // play the first one in the list
          nCurrentId = arrMyImagesArray[0] // (or whatever you use)
          } else {
          // play the next one
          nCurrentId++; // increase id by one
          } // if

          } else {
          // play selected image. leave nCurrentId as it is defined
          } // if


          // play image with nCurrentId

          // -------------------------------------------------------------------------
          -

          this is just one of the solutions you could follow!


          thank you
          stelios




          "mlamaudite" <webforumsuser@macromedia.com> wrote in message
          news:e9i9r9$nfa$1@forums.macromedia.com...
          > I am making a slideshow that randomly loads jpegs in a mc on the stage. I
          am trying to find a way to prevent flash to load the same image twice in a
          row.
          > Can anyone help me please?
          >
          > Thanks!!


          • 2. Re: randomly loading images that don't reapeat
            Rothrock Level 5
            In a hurry right now, but here is the general outline.

            Make an array of the names you want to load.
            Use the shuffle prototype to shuffle the array.
            Step through the array and load each clip one by one.
            There is no guarantee that when you get to the end and do it again that the same clip won't load twice. If that is a concern you will have to do some little check for that.

            Search the forums. This or variations of this are posted quite frequently.