onLoad (LoadVars.onLoad handler)

onLoad = function(success:Boolean) {}

Invoked when a LoadVars.load() or LoadVars.sendAndLoad() operation has ended. If the operation was successful, my_lv is populated with variables downloaded by the operation, and these variables are available when this handler is invoked.

This handler is undefined by default.

This event handler is similar to XML.onLoad.

Availability: ActionScript 1.0; Flash Player 6

Parameters

success:Boolean - A Boolean value that indicates whether the load operation ended in success (true) or failure (false).

Example

The following example adds a TextInput instance called name_ti, a TextArea instance called result_ta, and a Button instance called submit_button to the Stage. When the user clicks the Login button instance, two LoadVars objects are created: send_lv and result_lv. The send_lv object copies the name from the name_ti instance and sends the data to greeting.cfm. The result from this script loads into the result_lv object, and the server response is displayed in the TextArea instance (result_ta). Add the following ActionScript on Frame 1 of the Timeline:

var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
    var result_lv:LoadVars = new LoadVars();
    result_lv.onLoad = function(success:Boolean) {
        if (success) {
            result_ta.text = result_lv.welcomeMessage;
        } else {
            result_ta.text = "Error connecting to server.";
        }
    };
    var send_lv:LoadVars = new LoadVars();
    send_lv.name = name_ti.text;
    send_lv.sendAndLoad("http://www.flash-mx.com/mm/greeting.cfm", result_lv, "POST");
};
submit_button.addEventListener("click", submitListener);

For another example, see the Flash Samples page at www.adobe.com/go/learn_fl_samples. Download and decompress the Samples zip file and go to the ActionScript2.0\Login folder to access the login.fla file.

See also

onLoad (XML.onLoad handler), loaded (LoadVars.loaded property), load (LoadVars.load method), sendAndLoad (LoadVars.sendAndLoad method)


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001788.html