ADOBE DIRECTOR 11.0
User Guide
467
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
.
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 can be limitations 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
the same time usually adversely impacts performance.
When using network Lingo or JavaScript syntax, the current handler must finish before an operation’s result can
return. For best results, place script that initiates a network operation and script that uses the operation’s 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.
Execute a network script operation
1
Start the operation.
For example, the following statement initiates a text-downloading operation and assigns the network ID
returned by the
getNetText()
operation to the variable
theNetID
:
theNetID = getNetText("http://www.thenews.com")
2
Make sure that the operation finishes.
To check an operation’s status regularly until the method indicates that the operation is complete, use the
netDone()
method. For more information about this method, see the Scripting Reference topics in the Director
Help Panel.
For example, the following statement loops in the current frame until the download operation is complete:
if not(netDone(theNetID)) then _movie.go(_movie.frame)
3
Check whether the operation was successful by using the
netError()
method. For more information about this
method, see the Scripting Reference topics in the Director Help Panel.
4
Obtain the results if the operation is complete.
Note:
You can also use getStreamStatus() to determine the status of a network operation. You can use
netDone()
to
check whether an operation is “done” or “not done”. By using getStreamStatus(), you can check on an operation’s progress,
because it displays how many of the total number of bytes have downloaded.
Cancel a network operation in progress
•
Use the
netAbort()
method to cancel a network operation without waiting for a result. This frees up capacity
for Internet access, which lets other network operations finish faster. For more information about this method, see
the Scripting Reference topics in the Director Help Panel.