User Guide

474 Chapter 24: Using Shockwave Player
Checking whether media elements are loaded with Lingo or
JavaScript syntax
Director has several options that let an initial portion of a movie start playing as soon as the
required data and cast members are available. You can use Lingo or JavaScript syntax to check
whether media elements have been downloaded from a network by testing the following:
Whether a specific cast member is loaded before the movie proceeds
Whether the cast members used in a specific frame are loaded before the frame plays
Checking whether a cast member or sprite is loaded
To determine whether a specified cast member is available locally, you use the
mediaReady() cast
member or sprite property. You can check for a specific cast member or the cast member that is
assigned to a specific sprite. When
mediaReady() returns TRUE, the cast member is present on the
local drive and ready for loading into memory. For more information, see the Scripting Reference
topics in the Director Help Panel.
This property always returns
TRUE for local files. It is useful only for movies that stream from a
remote server. Because playback can begin before the entire movie has been downloaded, you
must make sure that necessary media elements have been downloaded as the movie plays.
Checking whether a frame’s contents are loaded
Use the
frameReady() method to determine whether all the media elements that the specified
frame requires are available locally. For more information about this method, see the Scripting
Reference topics in the Director Help Panel.
Downloading files from the Internet with Lingo or JavaScript
syntax
Lingo or JavaScript syntax uses the Internet’s resources by obtaining files from the Internet. The
data is copied to the local disk or cache. After data is available on the local computer, use these
scripts to retrieve the data for the movie. For more information, see “Retrieving network
operation results with Lingo or JavaScript syntax” on page 476.
For a movie or projector that plays outside a browser, background loading is not required.
However, preloading is a good idea because it improves playback performance.
All network Lingo or JavaScript syntax operations that obtain data from the network begin
downloading the data and return a network ID. The data is not immediately available.
An unlimited number of network Lingo or JavaScript syntax operations can take place at once.
However, depending on the browser chosen and the preferences set, there may be limitations set
on the number of network operations taking place. When multiple network Lingo or JavaScript
syntax operations run simultaneously, rely on the network ID that the method returns to
distinguish which operation is complete. Be aware that running more than four operations at
once usually adversely impacts performance.
When using network Lingo or JavaScript syntax, the current handler must finish before an
operations result can return. For best results, place script that initiates a network operation and
script that uses the operations result in different handlers. An
on exitFrame handler is a good
location for checking whether an operation is complete.
Note: You should typically use frame events rather than repeat loops for this process.