ActionScript for Flash MX: The Definitive Guide, Second Edition

ActionScript for Flash MX: The Definitive Guide, 2nd EditionBy Colin Moock
Chapter 18.  ActionScript Language Reference
LoadVars.loaded Property Flash 6

status of a load( ) or sendAndLoad( ) operation read/write

loadVarsObject.loaded

Description

The loaded property provides a quick means of determining whether variables have finished loading. For a new LoadVars object, loaded is set to undefined. After the first call to load( ) or sendAndLoad( ), loaded is set to false. If download never completes, due to an error or poor connection, it remains false. If download does complete, loaded is set to true by loadVarsObject.onData( ) and remains true until the next call to load( ) or sendAndLoad( ).

In most cases, LoadVars.onLoad( ) provides the best way to respond when variable loading completes. However, the loaded property is handy when a separate segment of code needs immediate access to the load status of a LoadVars object, as described in the following Example.

Example

Consider a game that loads high scores and offers a button to email scores to a friend. The button should work only if the scores are loaded, as follows:

// highScoreVars is assumed to be a global variable containing a LoadVars object emailButton.onRelease = function () { if (highScoreVars.loaded = = true) { // Proceed with email code... } else { // Variables aren't loaded. Tell user to wait... } }

See Also

LoadVars.onLoad( )

    Категории