ActionScript 3.0 introduces a number of formidable tools of communication, some totally new, some revised and improved from previous versions of ActionScript. We begin to see how it changes the way you interact with a Web Server in the case of a simple communication between Flash and a PHP page with the XML response. First of all, the object XML does not exist anymore! ActionScript 3.0 introduced new classes have been, some of which are dedicated to the "backward compatibility".
Note: The XML class (along with related classes) from ActionScript 2.0 have been renamed XMLDocument and moved to the flash.xml package. It is included in ActionScript 3.0 to ensure compatibility with previous versions.
usando il metodo sendAndLoad() dell'oggetto LoadVars (vedi: Flash: LoadVars e XML per inviare dati in POST ). In ActionScript 2.0 communication with a Web Server was often solved by using the combination of objects LoadVars and XML, using the method sendAndLoad() object LoadVars (see: Flash: LoadVars and XML to send data in POST ). Now things are changing, but you just get used to new names and objects. As indicated in the manual, in fact:
Continued ...
Here is a great way to send POST data to a Web Server. We will use two objects: a LoadVars object to send and to receive an XML object (in case we expect a return formatted XML document). Use the LoadVars object in Flash is useful for creating run-time properties that will be seen as POST variables for both the ability to specify the delivery method: POST or GET.
First of all we create the LoadVars object that will be used to ship:
1
| LoadVars = new LoadVars ( ) ; var s_lv: LoadVars = new LoadVars (); |
To this we add the POST variables in a very simple:
1 2
| ; s_lv. title = "Hello"; ; s_lv. subtitle = "Hello World"; |
Prepare the object that receives the response from the Web Server (in stdout) - if you just make a PHP echo:
1 2
| XML = new XML ( ) ; var r_xml: XML = new XML (); = true ; r_xml. ignoreWhite = true; |
At this point we can do is send:
1
| "http://miodominio.com/miapagina.php" , r_xml , "POST" ) ; s_lv. sendAndLoad ("http://miodominio.com/miapagina.php" r_xml, "POST"); |
The sendAndLoad () method of the LoadVars object is very ultile as it allows you to specify the object return (in this case our XML object r_xml) and the shipping method (in our case POST).
Finally just put on hold:
1 2 3 4 5
| ( success : Boolean ) { r_xml. onLoad = function (success: Boolean ) { success ) { if (success) { / / Processing results } }; |
Continued ...
Latest Comments
Simon : It annoys disturbed again and use that space for these things ... however it does not work ...
Giovambattista Fazioli : @ Simon: what could be due to the syntax I used, specifically for PHP 5 +,...
Simon : I tried last night putting everything into functions.php, okay, jquery forms, and tabs jQueryUI them ...
Giovambattista Fazioli : @ Simon: I recommend cleaning to enter a code like that in ...
Simon : @ Giovambattista Fazioli: Thank you for your patience, it's all clear ... now I feel now, ...