Incarnadine



 info/how to:


 multimedia:

 facs 2930
 facs 3930
 general






Randomness in Lingo

a version of this page for printing out



The following information assumes that you have used Director, and know basic navigational scripting. Some examples below will assume that you know how to make a shockwave movie, make HTML frames and can load a shockwave movie into a frame and alter other frames using the shockwave movie.


The Lingo command random() generates a random number between 1 and the number entered into the brackets.

The basic syntax for the command is:

random(x)
where x is the high number. If you want to randomly choose between 6 options, x would be the number 6, and you would randomly get one of these numbers: 1, 2, 3, 4, 5, 6


Examples:

1) When you rollover a sprite, it randomly beeps between 1 and 15 times:

on mouseenter

put random(15) into x

beep x

end


2) When you click on a sprite, it randomly goes to one of 3 different markers in the movie:

on mouseup

x = random(3)

if x = 1 then
    _movie.go("hammerheads")
else if x = 2 then
    _movie.go("basking")
else if x = 3 then
    _movie.go("whale")
end if

end


3) When you roll over a sprite, it randomly plays one of 8 different sounds in sound channel 1:

on mouseenter

x = random(8)

if x = 1 then
    sound(1).play(member("quietbuzzing"))
else if x = 2 then
    sound(1).play(member("buzzing"))
else if x = 3 then
    sound(1).play(member("loudbuzzing"))
else if x = 4 then
    sound(1).play(member("angrybuzzing"))
else if x = 5 then
    sound(1).play(member("scarybuzzing"))
else if x = 6 then
    sound(1).play(member("beesbuzzing"))
else if x = 7 then
    sound(1).play(member("alarmsbuzzing"))
else if x = 8 then
    sound(1).play(member("chameleonbuzzing"))
end if

end


4) Shockwave controlling frames example
When you click on a sprite, it randomly loads one of 3 webpages into a frame, and then goes to one of three markers in the shockwave movie:

on mouseup

put random(3) into x

if x = 1 then
    gotonetpage "elephantseal.html","topright"
    go to "elephant"
else if x = 2 then
    gotonetpage "weddellseal.html","topright"
    go to "weddell"
else if x = 3 then
    gotonetpage "harpseal.html","topright"
    go to "harp"
end if

end


5) Shockwave controlling frames example
When the shockwave movie leaves this frame, it loads a web page randomly into one frame or another frame (topright or topleft):

on exitframe

put random(2) into x

if x = 1 then
    gotonetpage "turn.html","topright"
else if x = 2 then
    gotonetpage "turn.html","topleft"
end if

end




back to top