Flash as learning: Loadvars.load download data from a specified URL address

Source: Internet
Author: User
Data | download

Function description
Download the data from the specified URL address and parse the contents of the data and store the results in the loadvarsobject. All downloaded variable contents are stored in Loadvarsobject in the form of a property, and the variable name is the property name of the Loadvarsobject, whose contents are case-sensitive. Therefore, any property name in Loadvarsobject that has the same name as the variable named in the download will be overwritten, and vice versa. These actions do not occur synchronously.
The downloaded data will be formatted as a string that conforms to the application/x-www-urlform-encoded specification, in the same format as loadvariables, such as: Name= frankc&age= 26&sex= Male, this data is also the return value of the data.
In the player prior to Flash version 7.0, use this method to read the specified SWF file to be accessed as long as all SWF files are located under the same parent domain.
In Flash version 7.0, however, when you use this method to read the specified SWF file to be accessed, you must specify the exact domain address. For example: SWF file in www.myDomain.com, can only access www.myDomain.com other SWF files, inaccessible example.myDomain.com files.
If you are accessing a different domain, you must place an XML file of the Cross-domain principle file (cross-domain Policy file) in the stored swf file.
The sample format is as follows:

<?xml version= "1.0"?>
<!--Http://www.myDomain.com/crossdomain.xml-->
<cross-domain-policy>
<allow-access-from domain= "www.SomeOf domain.com"/>
<allow-access-from domain= "*.mydomain.com"/>
<allow-access-from domain= "123.123.123.123"/>
</cross-domain-policy>

The function of this method is similar to that of Xml.load, and its security restrictions are the same.
Grammar
Myloadvars.load (URL);
Parameters
URL: The source address of the data to download
Statement Example
Myloadvars.load (http://www.myweb.com/my.php); Download the data from the www.myweb.com/my.php URL to the Myloadvars value object.
Use
Downloading data from a specified URL address
application Example

Script on the scene frame
Stop ();
LV = new Loadvars ();
Lv.load ("Data.txt");
Script on the button
On (release) {
if (lv.loaded = = True) {
NextFrame ();
}
}

Execution results
Click the button, the program will first determine whether the external variable value has been loaded, if the load will appear a new screen and display its value.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.