Table of Contents

LoadVars.onData( ) Event Handler Flash 6 (undocumented)

handler executed when external variable data finishes loading, but before it is parsed
loadVarsObject.onData(src);

Arguments

src

A string containing raw URL-encoded variables.

Description

The onData( ) handler executes automatically when raw variables requested by load( ) or sendAndLoad( ) have finished downloading but have not yet been parsed.

The onData( ) handler can be assigned a custom callback function to intercept raw variable source before ActionScript has a chance to convert the URL-encoded variables to loadVarObject properties and before onLoad( ) is called. This unmediated access to data loaded from the server can be useful for debugging. However, in most other cases a custom callback for onData( ) is not required.

By default (unless you define a custom callback function), onData( ) has the following behavior:

When implementing onData( ), be sure to convert the loaded variables to properties via decode( ), as shown in the following Example.

Example

The following example shows how to display raw loaded-variable source while preventing it from being parsed by ActionScript. The onLoad( ) method is not called, and the loaded property is not set:

loadedVars = new LoadVars();
loadedVars.onData = function (src) {
  trace("Variables received: " + src);
};
loadedVars.load("http://www.thesite.com/cgi-bin/getData.pl");

Here we display raw loaded-variable source but call onLoad( ) as it normally would be. Note that we take care to recreate all the default onData( ) behavior, including converting the loaded variables to properties with decode( ) and setting the loaded property to true:

loadedVars = new LoadVars();
loadedVars.onData = function (src) {
  trace("Variables received: " + src);
  if (src =  = undefined) {
    this.onLoad(false);
  } else {
    this.decode(src);
    this.loaded = true;
    this.onLoad(true);
  }
};
   
loadedVars.onLoad = function (success) {
  trace("Vars load successfully? " + success);
}
   
loadedVars.load("http://www.thesite.com/cgi-bin/getData.pl");

See Also

LoadVars.decode( ), LoadVars.onLoad( )


Table of Contents