Posted By

arpo on 12/30/08


Tagged

form get database data post server ASP


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

shoffa
iamgowan
Bonky
tspitzr


Basic post to server


 / Published in: ActionScript 3
 

Post data from Flash, AS3 to a server

  1. import flash.net.*
  2.  
  3. send();
  4.  
  5. function send():void{
  6. var variables:URLVariables = new URLVariables();
  7. variables.yourName = "Joe";
  8. variables.yourAge = "44";
  9.  
  10. var request:URLRequest = new URLRequest("http://www.messyou.se/flashGet.asp"); //Insert your own URL here.
  11. request.method = URLRequestMethod.POST;
  12. request.data = variables;
  13. var loader:URLLoader = new URLLoader();
  14. loader.dataFormat = URLLoaderDataFormat.VARIABLES;
  15. loader.addEventListener(Event.COMPLETE, completeHandler);
  16. try{
  17. loader.load(request);
  18. }
  19. catch (error:Error) {
  20. trace("Unable to load URL");
  21. }
  22. }
  23.  
  24. function completeHandler(event:Event):void{
  25. var variables:URLVariables = new URLVariables(event.target.data);
  26. var msg = variables.msg;
  27. if(msg=="true"){
  28. trace("Done!");
  29. } else{
  30. trace("Error: "+msg);
  31. }
  32. }
  33.  
  34. //Server side file in Classic ASP
  35. /*
  36. <%
  37. if true then
  38. response.write("msg=" & Server.UrlEncode("true"))
  39. else
  40. response.write("msg=" & Server.UrlEncode("Sorry didn't work"))
  41. end if
  42. %>
  43. */

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: liange on June 21, 2011

This is a very good example for the server side programming. I dont know flash but still can get idea of this program flow. london seo company

You need to login to post a comment.