User Guide
490 Chapter 12: Methods
This handler randomly chooses which of two movie segments to play:
-- Lingo syntax
on SelectScene
if (random(2) = 2) then
_movie.go("11a")
else
_movie.go("11b")
end if
end
// JavaScript syntax
function SelectScene() {
if (random(2) == 1) {
_movie.go("11a");
} else {
_movie.go("11b");
}
}
This statement produces a random multiple of 5 in the range 5 to 100:
-- Lingo syntax
theScore = (5 * random(20))
// JavaScript syntax
var theScore = (5 * random(20));
randomVector()
Usage
-- Lingo syntax
randomVector()
// JavaScript syntax
randomVector();
Description
Top level function; returns a unit vector describing a randomly chosen point on the surface of a
unit sphere.
This function differs from
vector(random(10)/10.0, random(10)/10.0, random(10)/
10.0,)
in that the resulting vector using randomVector() is guaranteed to be a unit vector.
A unit vector always has a length of one.
Parameters
None.