5 Replies Latest reply on May 8, 2006 4:41 PM by Newsgroup_User

    Randomly select a marker

    Bhavzzz
      Hi,

      I wanted to know if it was possible to get director to randomly select a marker from the main movie, for example if I had four markers such as 'Marker 1'.'Marker 2', 'Marker 3’ etc... Would I be able to guide director using lingo to randomly select a marker when a button is pressed and then play that part of the movie. Any help would be appreciated.

      Thank you
        • 1. Re: Randomly select a marker
          Level 7
          the markerList[random(count(the markerList))]

          The above statement will randomly select a marker from all of the markers in
          the movie. I suspect that you may want something that will let you choose
          random markers such that any previously selected markers won't be chosen. In
          that case its a little more involved, but not difficult. Add a movie script
          such as:

          -------------------------------
          global gAvailableMarkers

          on startMovie
          gAvailableMarkers = duplicate(the markerList)
          end

          on getRandomMarker myList
          if count(myList) = 0 then
          return 0
          else
          randomNumber = count(myList)
          randomMarker = myList[randomNumber]
          myList.deleteAt(randomNumber)
          return randomMarker
          end if
          end
          ------------------------------

          Now you can call the function like this

          getRandomMarker(gAvailableMarkers)

          This will return one of the markers in the list gAvailableMarkers and remove
          that item from the list as well so that next time you call the function, it
          will not return any previously selected markers. The function returns 0 if
          the list is empty.




          • 2. Re: Randomly select a marker
            Bhavzzz Level 1
            Thanks, i'll try that.
            • 3. Re: Randomly select a marker
              Level 7
              Sorry, there was a error in the code. It wasn't actually choosing random
              numbers. Here is a correction.

              on getRandomMarker myList
              if count(myList) = 0 then
              return 0
              else
              the randomSeed = the ticks
              randomNumber = random(count(myList))
              randomMarker = myList[randomNumber]
              myList.deleteAt(randomNumber)
              return randomMarker
              end if
              end


              • 4. Re: Randomly select a marker
                Level 7
                If you like to use all dot syntax and not mix old and new then.

                the markerList [((the markerList).count).random]

                The similar changes would apply to the longer piece of code that Dave was
                kind enough to provide.

                Craig


                --
                Craig Wollman
                Word of Mouth Productions

                phone 212 928 9581
                fax 212 928 9582
                159-00 Riverside Drive West #5H-70
                NY, NY 10032
                www.wordofmouthpros.com


                "Dave C" <private@email.com> wrote in message
                news:e3lafs$gu5$1@forums.macromedia.com...
                > the markerList[random(count(the markerList))]
                >
                > The above statement will randomly select a marker from all of the markers
                > in
                > the movie. I suspect that you may want something that will let you choose
                > random markers such that any previously selected markers won't be chosen.
                > In
                > that case its a little more involved, but not difficult. Add a movie
                > script
                > such as:
                >
                > -------------------------------
                > global gAvailableMarkers
                >
                > on startMovie
                > gAvailableMarkers = duplicate(the markerList)
                > end
                >
                > on getRandomMarker myList
                > if count(myList) = 0 then
                > return 0
                > else
                > randomNumber = count(myList)
                > randomMarker = myList[randomNumber]
                > myList.deleteAt(randomNumber)
                > return randomMarker
                > end if
                > end
                > ------------------------------
                >
                > Now you can call the function like this
                >
                > getRandomMarker(gAvailableMarkers)
                >
                > This will return one of the markers in the list gAvailableMarkers and
                > remove
                > that item from the list as well so that next time you call the function,
                > it
                > will not return any previously selected markers. The function returns 0 if
                > the list is empty.
                >
                >
                >
                >


                • 5. Re: Randomly select a marker
                  Level 7
                  ..or dom lingo:

                  put _movie.markerList[random(_movie.markerList.count)]

                  --
                  Dave -
                  Adobe Community Expert
                  www.blurredistinction.com
                  www.macromedia.com/support/forums/team_macromedia/