
random()
489
This statement determines whether the memory needed to display frames 100 to 125 is more
than the available memory, and, if it is, branches to the section using cast members that have
lower color depth:
-- Lingo syntax
if (_movie.ramNeeded(100, 125) > _system.freeBytes) then
_movie.go("8-bit")
end if
// JavaScript syntax
if (_movie.ramNeeded(100, 125) > _system.freeBytes) {
_movie.go("8-bit");
}
See also
freeBytes()
,
Movie
random()
Usage
-- Lingo syntax
random(
integerExpression
)
// JavaScript syntax
random(
integerExpression
);
Description
Top level function; returns a random integer in the range 1 to a specified value. This function can
be used to vary values in a movie, such as to vary the path through a game, assign random
numbers, or change the color or position of sprites.
To start a set of possible random numbers with a number other than 1, subtract the appropriate
amount from the
random()
function. For example, the expression
random(n + 1) - 1
uses a
range from 0 to the number
n
.
Parameters
integerExpression
Required. Specifies the maximum value of the random number.
Example
This statement assigns random values to the variable
diceRoll
:
-- Lingo syntax
diceRoll = (random(6) + random(6))
// JavaScript syntax
var diceRoll = (random(6) + random(6));
This statement randomly changes the foreground color of sprite 10:
-- Lingo syntax
sprite(10).foreColor = (random(256) - 1)
// JavaScript syntax
sprite(10).foreColor = (random(256) - 1);
Содержание DIRECTOR MX 2004-DIRECTOR SCRIPTING
Страница 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Страница 48: ...48 Chapter 2 Director Scripting Essentials...
Страница 100: ...100 Chapter 4 Debugging Scripts in Director...
Страница 118: ...118 Chapter 5 Director Core Objects...
Страница 594: ...594 Chapter 12 Methods...
Страница 684: ...684 Chapter 14 Properties See also DVD...
Страница 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Страница 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Страница 889: ...netPresent 889 _player alert Sorry the Network Support Xtras could not be found See also Player...
Страница 1102: ...1102 Chapter 14 Properties...