/ Published in: ActionScript
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
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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();