
Preloading digital video
439
Using script 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 is
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 script methods you can use to force specific cast members to load into memory
or unload from memory. By using these methods, 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 methods to control cast member loading and unloading:
•
To load a specific cast member or set of cast members, use the
preLoadMember()
method.
•
To load all the cast members used in a specific frame or range of frames, use the
preLoad
method.
•
To unload a specific cast member or set of cast members from memory, use the
unLoadMember()
method.
•
To unload all the cast members used in a specific frame of your movie, use the
unload
method.
•
To determine the number of bytes of memory required to display a range of frames, use the
ramNeeded()
method. 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()
method.
There are several more script terms related to memory management. For a complete list, see the
Scripting Reference topics in the Director Help Panel.
Preloading digital video
It is recommended that you do not preload digital video cast members. Digital video is played by
streaming the video file from a disk. As the file is streamed, it is decompressed into memory one
section at a time. Preloading a digital video file causes the entire file to be decompressed into
memory at once, which can cause low memory situations on most computers.
You can cause a digital video to preload only its first segment without consuming unnecessary
memory by placing it in the Score a frame or two before it is actually needed.
To preload a digital video safely:
1
Add a sprite of the digital video to the Score.
2
Begin the sprite one or two frames before the frame where you want to display the video.
3
Locate this sprite off the Stage except for at least one pixel of one corner of the sprite. This is so
the user won’t notice it.
4
Set the sprite’s
movieRate
property to 0, which prevents the movie from playing when
first loaded.
Содержание DIRECTOR MX 2004-USING DIRECTOR
Страница 1: ...DIRECTOR MX 2004 Using Director...
Страница 16: ...16 Chapter 1 Introduction...
Страница 82: ...82 Chapter 3 Sprites...
Страница 98: ...98 Chapter 4 Animation...
Страница 134: ...134 Chapter 5 Bitmaps...
Страница 242: ...242 Chapter 10 Sound and Synchronization...
Страница 274: ...274 Chapter 11 Using Digital Video...
Страница 290: ...290 Chapter 12 Behaviors...
Страница 302: ...302 Chapter 13 Navigation and User Interaction...
Страница 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Страница 392: ...392 Chapter 16 Working with Models and Model Resources...
Страница 418: ...418 Chapter 18 Movies in a Window...
Страница 446: ...446 Chapter 22 Managing and Testing Director Projects...