// JSON support
Import com. adobe. serialization. json. JSON;
Public class Net extends Sprite
{
Public function Net ()
{
// Communicates with ASP. NET in text format
ShowText ();
// Communicate with ASP. NET in XML format
ShowXml ();
// Communicate with ASP. NET in JSON format
ShowJSON ();
}
// Communicates with ASP. NET in text format
Function showText (): void
{
Var v: URLVariables = new URLVariables ("name = webabcd & age = 27 ");
Var r: URLRequest = new URLRequest ();
R. url = "http: // localhost: 1343/Web/Text. aspx ";
R. method = URLRequestMethod. GET;
R. data = v;
Var l: URLLoader = new URLLoader ();
L. load (r );
L. addEventListener (Event. COMPLETE, textCompleteHandler );
}
Function textCompleteHandler (event: Event): void
{
Var l: URLLoader = URLLoader(event.tar get );
// Communicate with ASP. NET in XML format
Function showXml (): void
{
Var v: URLVariables = new URLVariables ()
Var r: URLRequest = new URLRequest ();
R. url = "http: // localhost: 1343/Web/Xml. aspx ";
R. method = URLRequestMethod. GET;
R. data = v;
Var l: URLLoader = new URLLoader ();
L. load (r );
L. addEventListener (Event. COMPLETE, xmlCompleteHandler );
}
Function xmlCompleteHandler (event: Event): void
{
Var l: URLLoader = event.tar get as URLLoader;
Var xml: XML = new XML (l. data );
For each (var v in xml. person)
{
Trace ("name:" + v. @ name + "; age:" + v. @ age + "; salary:" + v. salary );
}
// Output:
// Name: webabcd; age: 27; salary: 1000
// Name: webabcdefg; age: 37; salary: 2000
// Name: webabcdefghijklmn; age: 47; salary: 30
}
// Communicate with ASP. NET in JSON format
Function showJSON (): void
{
Var v: URLVariables = new URLVariables ()
Var r: URLRequest = new URLRequest ();
R. url = "http: // localhost: 1343/Web/JSON. aspx ";
R. method = URLRequestMethod. GET;
R. data = v;
Var l: URLLoader = new URLLoader ();
L. load (r );
L. addEventListener (Event. COMPLETE, jsonCompleteHandler );
}
Function jsonCompleteHandler (event: Event): void
{
Var l: URLLoader = event.tar get as URLLoader;
Var v: * = JSON. decode (l. data );
Trace ("Name:" + v. Name + "; Age:" + v. Age );
// Output: Name: webabcd; age: 27
}
}
}
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