
LoadVars.onLoad() Event Handler
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
584
|
ActionScript Language Reference
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( )
LoadVars.onLoad() Event Handler
handler executed after ...