you can use the random() method
-- behavior script attached to your 'random' button
on mouseUp me
i = 120 -- number of songs
rnd = random(120)
without more information on how you have things configured there's really no way to help.
You can use random() to choose a random number. If you have 17 song titles, then you could use:
vRandomSongNumber = random(17)
Suppose your other buttons do something like this:
PlaySong(3) -- or whatever system you use to decide which song to play
Your random button could do this:
vRandomSongNumber = random(17) -- or however many songs there are to choose from
Does that help?
umm...kinda?...I'm sorry i am a beginner at Director...only an A2 student!We only have to have 3 songs....Right! to get it to go to the next page, i have the markey way, so on Mouse Down, go to Marker 7 for example...umm...how would i do that with the random button thing?....do i enter the name of the song after it?....the sprite number?...i am so confused...
Let's imagine that your song markers are at frames 7, 14 and 35 (I've deliberately chosen frames which are not consecutive). You could create a list of frame numbers:
vSongFrames = [7, 14, 35]
The behavior on your Random button could look like this:
vSongFrames = [7, 14, 35] -- <HARD-CODED>
vSongCount = vSongFrames.count
vRandomSong = random(vSongCount)
vRandomFrame = vSongFrames[vRandomSong]
What does this do? It stores all your data concerning the frames that you could jump to in one place. If you change the frame numbers, or the number of songs, you make that change in just one place. In the next 4 lines, the code:
- Calculates how many songs you have, using the list of frame numbers as a guide
- Chooses one of those songs at random
- Works out which frame that song starts on
- Jumps to that frame
It's not normally a good idea to use hard-coded frame numbers. You might decide to add frames or move the markers in the Score. If you did that, the behavior would no longer work. It would be better to use frame labels...
vSongFrames = ["Name of marker for first song", "Second song", "Third song"]
... where the strings you use in the list are identical to the names of the markers in your movie. You would still be hard-coding data, but that data is less likely to change. Assuming that the marker label at frame 14 is "Second Song" then the commands...
go "Second Song"
... have exactly the same effect.
Thank you so much! That was a lot of help! Thanks for doing it step by step as well!
How about for example the frame start with 10 - 20 and the frame interval is 2 , then how would you randomized the frame without repeating the number? thanks !!!
Please help me!!! i'm just a student and i am working my special project called CAI.... thanks a lot for scrutinizing my message..
I'm not sure I understand your question, but supposing your frame numbers were placed in a list it might look like:
lFrames = [10, 12, 14, 16, 18, 20]
Then you could choose one of those items like James outlined. In order to not repeat the number you would remove it from the list