Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 1.31 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Communation between ASP.Net and Flash CS5
  2. <embed height= "500px" type="application/x-shockwave-flash" width="500px" src="../Untitled-3.swf" fullscreen="no"></embed>
  3.        
  4. btn.addEventListener(MouseEvent.MOUSE_DOWN,senddata);
  5. function senddata(e:MouseEvent)
  6. {
  7. var scriptRequest:URLRequest = new URLRequest("../WebForm1.aspx");
  8. var scriptLoader:URLLoader = new URLLoader();
  9. var scriptVars:URLVariables = new URLVariables();
  10.  
  11. scriptLoader.addEventListener(Event.COMPLETE, handleLoadSuccessful);
  12. scriptLoader.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError);
  13.  
  14. scriptVars.var1 = "one";
  15.  
  16.  
  17. scriptRequest.method = URLRequestMethod.POST;
  18. scriptRequest.data = scriptVars;
  19.  
  20. scriptLoader.load(scriptRequest);
  21.  
  22. function handleLoadSuccessful($evt:Event):void
  23. {
  24.     txt.text="sent";
  25.     trace("Message sent.");
  26. }
  27.  
  28. function handleLoadError($evt:IOErrorEvent):void
  29. {
  30.     txt.text="failed";
  31.     trace("Message failed.")
  32. }
  33. }
  34.        
  35. public partial class WebForm1 : System.Web.UI.Page
  36.     {
  37.         protected void Page_Load(object sender, EventArgs e)
  38.         {
  39.  
  40.  
  41.                 if (!Page.IsPostBack)
  42.                 {
  43.  
  44.  
  45.                     if (Request.Form["var1"] != null)
  46.                     {
  47.                         TextBox1.Text = Request.Form["var1"];
  48.  
  49.                     }
  50.  
  51.                 }
  52.  
  53.  
  54.         }
  55.        
  56. TextBox1.Text = Request.Form["var1"];