Chapter 24
564
Whenever Director runs low on memory, such as when trying to load many large cast members,
other cast members are automatically unloaded from memory, according to the following rules:
•
The first cast members to be unloaded are those that have a
purgePriority
value of 3. This
type of discarding is fast but is essentially random, which means you cannot predict which of
these cast members will be unloaded at any given time. The worst-case scenario is that in order
to load the cast member for channel 1 of a particular frame, the cast member that will be
needed for channel 2 of that same frame gets unloaded.
•
When there are no more cast members with a
purgePriority
value of 3 left to unload,
Director starts unloading the cast members that have a
purgePriorty
value of 2 and were least
recently used. This type of unloading is slower but can be more predictable.
•
If more memory is still needed after the cast members with a
purgePriority
value of 2
are unloaded, then the least recently used cast members with a
purgePriority
value of 1
are unloaded.
Using Lingo to change a cast member’s
purgePriority
property is a good technique for
controlling memory management. However, changes to the
purgePriority
property do not take
effect until the next time a cast member is used. For example, if you change the property in an
exitFrame
or
enterFrame
script in the same frame as a cast member is used, the cast member
will be treated as if it had its old priority because all drawing on the screen is done before any
enterFrame
or
exitFrame
scripts are performed.
Loading and unloading individual cast members
There are several Lingo commands you can use to force specific cast members to load into
memory or unload from memory. By using these commands, you can unload cast members that
you know are no longer in use to make room for new ones. You can also force large cast members
to load before they are actually needed. This prevents a pause that can occur when large cast
members load normally, just before being drawn on the Stage.
Use the following Lingo terms to control cast member loading and unloading:
•
To load a specific cast member or set of cast members, use the
preLoadMember()
command.
•
To load all the cast members used in a specific frame or range of frames, use the
preLoad
command.
•
To unload a specific cast member or set of cast members from memory, use the
unLoadMember()
command.
•
To unload all the cast members used in a specific frame of your movie, use the
unload
command.
•
To determine the number of bytes of memory required to display a range of frames, use the
ramNeeded()
function. To convert the number of bytes to kilobytes, divide the result by 1024.
•
To determine the current amount of available memory, use the
freeBytes()
or
freeBlock()
function.
There are several more Lingo terms related to memory management. For a complete list, see
Memory management in the Lingo by feature section of the Lingo Dictionary.
Содержание DIRECTOR MX-USING DIRECTOR MX
Страница 1: ...Using Director MX Macromedia Director MX...
Страница 12: ...Contents 12...
Страница 156: ...Chapter 4 156...
Страница 202: ...Chapter 6 202...
Страница 244: ...Chapter 7 244...
Страница 292: ...Chapter 10 292...
Страница 330: ...Chapter 12 330...
Страница 356: ...Chapter 13 356...
Страница 372: ...Chapter 14 372...
Страница 442: ...Chapter 16 442...
Страница 472: ...Chapter 18 472...
Страница 520: ...Chapter 19 520...
Страница 536: ...Chapter 20 536...
Страница 562: ...Chapter 23 562...
Страница 566: ...Chapter 24 566...
Страница 602: ...Chapter 27 602...