Return to Snippet

Revision: 5978
at April 18, 2008 11:51 by chrisaiv


Initial Code
var emailServer:String = "http://server.com/email.php"

var request:LoadVars = new LoadVars();
var response:LoadVars = new LoadVars();
	response.onLoad = showResult;

/************************
Server Request
************************/
function sendEmail():Void{
	request.name = "chrisaiv";
	request.email = "[email protected]";
	request.url = "http://sendtoafriend";
	request.sendAndLoad(emailServer + "?clearCache=" + new Date().getTime(), response, "GET");

	//Show data sent
	for (var prop in request){
		//trace( request[prop] + newline);
	}
}

/************************
Server Response
************************/
function showResult():Void{
	if (this.success) {
		trace("File path: " + this.success);
	}
}

sendEmail();

Initial URL

                                

Initial Description
This is pretty handy if you need to make a request to a server and receive a response.  For example, you want to send an e-mail in Flash using some PHP script.  On the PHP side, request will be sent as

Initial Title
AS2: Simple Send and Load

Initial Tags

                                

Initial Language
ActionScript