Flash communicates with Asp over Http. The request format is http: // ip address? Parameter 1 = value 1 & Parameter 2 = value 2
That is, add a question mark after the destination address and keep up with the parameter string. Separate the parameters with the Ampersand. For example:
Http://www.pcedu.com.cn/test.asp? Userid = guest & pwd = 123
In the preceding request, the target file of the request is.
The interaction between Flash and Asp is nothing more than constructing the above request string.
1. In Flash, the request string is constructed first, and then the LoadVariables () function can be used to send requests and parameters to the server. Let's take a closer look at the LoadVariables () function.
The standard function format is loadVariables.
("Url", level/"target "[,
Variables])
In each parameter of the function, the url is the request string mentioned above. Level/"target" indicates the "level" or "target" of the returned value. Only one of the two levels can be specified. Variables is the request method. The value can be "Get" or "Post". Generally, Get is used for transmitting the parameter value in a short manner, and Post is used for transmitting the parameter value in a long manner, this parameter is optional. For example, loadVariables
("Http://www.pcedu.com.cn/guest.asp? Userid = guest & pwd = 123 ", 0,
"GET") is a complete request.
2. In Asp, the parameters transmitted from Flash must be obtained first, which is the same as operating common HTML forms. The Request object is used, and its statement is:
Username
= Request ("userid ")
Password =
Request ("pwd ")
Userid and pwd are the parameter names sent from the Flash end. If they are the request strings in the previous step, the username value is guest and the pwd value is 123.
3. After processing the request on the server end and obtaining the required value, Asp sends the result to the Flash end. Like the Html language used in Asp, the Response object is used. The statement is:
Response. Write ("login = true & des = success ")
The value of 1 is login, the value is true, the value of 2 is des, and the value is success.
4. Obtain the value returned from the server on the Flash end, which is no different from the common variables in Flash. For example:
_ Root. gotoAndPlay (eval (login) indicates the frame to jump to the login value. However, it should be noted that the returned value can be used only after a request is sent for a period of time. Otherwise, the returned value is not returned, and errors are inevitable, and such errors are hard to be found, be careful when using it.
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