LoadVars.loaded Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By 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( )



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net