Public sendandload (URL: String, target: object, [method: String]): Boolean
SetMy_lvThe variables in the object are sent to the specified URL. Download the server response, analyze it as the variable data, and place the result variable inTargetObject.
How variables are sent andLoadvars. Send ()Same. Download variableTargetMethod andLoadvars. Load ()Same.
When using this method, consider the Flash Player Security Model:
For Flash Player 8:
- If the SWF file to be called is in a sandbox that can only interact with the content of the local file system, and the target resource is from the network sandbox, data loading is not allowed.
- If the SWF file to be called comes from the network sandbox and the target resource is local, data loading is not allowed.
For more information, see the following section:
- Learning about security in Flash 2.0"
- Flash Player 9 Security White Paper in http://www.adobe.com/go/fp9_0_security_cn)
- Flash Player 8 security-related API whitepaper in http://www.adobe.com/go/fp8_security_apis_cn)
For Flash Player 7 and later versions:
- A website can use a cross-origin policy file to allow cross-origin access to resources.
- In any SWF file running in Flash Player 7 and later versions,URLMust be in the same domain. For example, SWF files at www.somedomain.com can only load data from sources that are also at www.somedomain.com.
If the SWF file is running in a player earlier than Flash Player 7URLIt must be in the same super domain as the SWF file that issued this call. A super domain can be obtained by deleting the leftmost component of a File URL. For example, the SWF file at www.somedomain.com can load data from the source at store.somedomain.com because both files are in the same super domain named somedomain.com.
This method worksXML. sendandload ()Similar.
Availability:The action in WordPress 1.0 and Flash Player 6-Flash Player 7 has been changed.
Parameters
URL:String: A string; the destination URL of the uploaded variable. If the SWF file that sends this call is running in a Web browserURLIt must be in the same domain as the SWF file.
Target:Object-The loadvars or XML object that receives the downloaded variable.
Method:String [Optional]-A string; http protocolGetOrPostMethod. The default value isPost.
Return
Boolean: A boolean value.
Example
For the following example, add the nameName_tiThe textinput instance namedResult_taTextarea instance andSubmit_button. When you click the login button in the following example, two loadvars objects are created:Send_lvAndResult_lv.Send_lvObject slaveName_tiCopy the Instance name and send the data to greeting. cfm. The result of this script will be loadedResult_lvThe server response is displayed in the textarea instance (Result_ta. Add the following ActionScript to the 1st frame in 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 other examples, see the flash Example page at www.adobe.com/go/learn_fl_samples_cn. Download and decompress the sample ZIP file, and enter the actionscript2.0 \ login folder to access the login. FLA file.