PDA

View Full Version : convert as 2.0 code to as 3.0 Help


kishorpapnai
08-27-2008, 09:13 AM
hi All,
I was using action script 2.0 for last some time, now i am migrating to action script 3.0, and facing some prob to parsing xml to send to php file. bellow code works fine in action script 2.0,

can someone please help me to convert bellow action script 2.0 code to action script 3.0 code.


var sendXML:XML = new XML();
var mainNode:XMLNode = sendXML.createElement("DataSet")
sendXML.appendChild(mainNode)
var mainNode1:XMLNode = sendXML.createElement("Data");
mainNode.appendChild(mainNode1)
var mainNodeValue:XMLNode = sendXML.createTextNode("Please Help Me")
mainNode1.appendChild(mainNodeValue) //on button press event
var xyz:XML = new XML();
sendXML.sendAndLoad("abc.php", xyz)


Thanks In Advance:eek:
Kishor

kishorpapnai
08-27-2008, 10:20 AM
hi All,
I was using action script 2.0 for last some time, now i am migrating to action script 3.0, and facing some prob to parsing xml to send to php file. bellow code works fine in action script 2.0,

can someone please help me to convert bellow action script 2.0 code to action script 3.0 code.


var sendXML:XML = new XML();
var mainNode:XMLNode = sendXML.createElement("DataSet")
sendXML.appendChild(mainNode)
var mainNode1:XMLNode = sendXML.createElement("Data");
mainNode.appendChild(mainNode1)
var mainNodeValue:XMLNode = sendXML.createTextNode("Please Help Me")
mainNode1.appendChild(mainNodeValue) //on button press event
var xyz:XML = new XML();
sendXML.sendAndLoad("abc.php", xyz)


Thanks In Advance:eek:
Kishor

rawmantick
08-27-2008, 10:23 AM
Use XMLDocument instead of XML. Rest is the same.

rawmantick
08-27-2008, 10:29 AM
Avoid duplicated threads and stupid thread names like "Pleeez heeelp!".

Some people would like to help you, if you know what you need. If you write "aaahhh it doesn't work", they will miss you question.

Thread name should be "self representative"!

kishorpapnai
08-27-2008, 10:46 AM
sorry man..... don't b irritate, i m just asking for help ?

hv u any idea how to convert this code to action script 3.0 (in new xml parsing approch of action script 3.0)

kishorpapnai
08-27-2008, 11:01 AM
thanks mate!

Sicontis
08-27-2008, 11:03 AM
// Create a new XML instance containing the data to send
var str:String = "Please help me!";
var sendXML:XML = <Dataset>
<Data>{str}</Data>
</Dataset>;

// Point the request to the script that will handle the XML
var request:URLRequest = new URLRequest( "abc.php" );

// Set the data property to the sendXML XML instance to send the XML
// data to the server
request.data = sendXML;

// Set the contentType to signal XML data being sent
request.contentType = "text/xml";

// Use the post method to send the data
request.method = URLRequestMethod.POST;


// Create a URLLoader to handle sending and loading of the XML data
var loader:URLLoader = new URLLoader();

// When the server response is finished downloading, invoke handleResponse
loader.addEventListener( Event.COMPLETE, handleResponse );

// Finally, send off the XML data to the URL
loader.load(request);


function handleResponse(event:Event):void {
try {
// Convert the server's response into XML
var success:XML = new XML(event.target.data);

// Use XML routines to read XML nodes

} catch (e:TypeError) {
// Display an error message since the server response was not understood
trace(e);
}
}

kishorpapnai
08-27-2008, 11:18 AM
thanks for this heplfull code with comments

CyanBlue
08-27-2008, 02:18 PM
Please keep your question to one thread... Crossposts merged...