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.
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...