Created
February 13, 2010 00:47
-
-
Save laktek/303159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mx.collections.ArrayCollection; | |
import mx.rpc.events.ResultEvent; | |
import com.adobe.serialization.json.JSON; //download from http://code.google.com/p/as3corelib/ | |
function initateGame(playerId):void | |
{ | |
var dataToSave = [playerId]; | |
// Point the request to the script that will handle the JSON | |
var request:URLRequest = new URLRequest( "http://localhost:8000" ); | |
// Set the data property to the dataToSave XML instance to send the XML | |
// data to the server | |
request.data = JSON.encode(dataToSave); | |
//request.data = variables; | |
// Set the contentType to signal JSON data being sent | |
request.contentType = "application/json"; | |
// Use the post method to send the data | |
request.method = URLRequestMethod.POST; | |
// Create a URLLoader to handle sending and loading of the JSON 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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment