pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

swx private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Omi on Mon 28 Jul 03:07
report abuse | View followups from Omi | download | new post

  1. //////////////////////////////////////////////////////////////////////
  2. //
  3. // Add numbers sample application.
  4. //
  5. // Copyright (c) 2007 Aral Balkan.
  6. // All SWX sample applications are released under the open source
  7. // MIT License (http://www.opensource.org/licenses/mit-license.php).
  8. //
  9. // This version uses the SWX ActionScript Library.
  10. //
  11. // The SWX ActionScript Library gives you a completely abstract and
  12. // high-level way of working with SWX RPC. It is the recommended way
  13. // to use SWX RPC in your applications unless you need the
  14. // flexibility that the native methods give you (which you may do,
  15. // for example, if you want to create your own high-level library.)
  16. //
  17. //////////////////////////////////////////////////////////////////////
  18. import org.swxformat.*;
  19. import mx.utils.Delegate;
  20.  
  21. var swx:SWX;
  22.  
  23. function init()
  24. {
  25.         // Set up the display
  26.         progressIndicator._visible = false;
  27.        
  28.         n1.restrict = "0-9.\\-";
  29.         n2.restrict = "0-9.\\-";
  30.  
  31.         // Listen for the click event on the add button
  32.         addButton.addEventListener("click", Delegate.create(this, addButtonClickHandler));
  33.  
  34.         // Create a new SWX object
  35.         swx = new SWX();
  36.         swx.gateway = "http://swxformat.org/php/swx.php";
  37.         swx.encoding = "GET";
  38.        
  39.         // By default, this example uses the public SWX gateway on swxformat.org.
  40.         // To use the local gateway instead, uncomment the following line (Unless
  41.         // you're using the SWX  MAMP Bundle, you will most likely have to alter
  42.         // the URL below to point to your local installation of SWX PHP.)
  43.         //
  44.         // swx.gateway = "http://localhost:8888/php/swx.php";   
  45. }
  46.  
  47. init();
  48.  
  49. // Load the movie
  50. function addButtonClickHandler()
  51. {
  52.         // Set call details.   
  53.         var callDetails:Object =
  54.         {
  55.                 serviceClass: "Simple",
  56.                 method: "addNumbers",
  57.                 args: [n1.text, n2.text],
  58.                 result: [this, resultHandler],
  59.                 timeout: [this, timeoutHandler],
  60.                 debug: true
  61.         }
  62.        
  63.         // Carry out SWX call.
  64.         swx.call(callDetails);
  65.        
  66.         isLoading(true);
  67. }
  68.  
  69. function resultHandler(event:Object)
  70. {
  71.         // Load is complete.
  72.         isLoading(false);
  73.        
  74.         // Display the result.
  75.         sum.text = event.result;
  76. }
  77.  
  78. function timeoutHandler(event:Object)
  79. {
  80.         // Call timed out.
  81.         isLoading(false);
  82.         status.text = "The call timed out. Please try again.";
  83. }
  84.  
  85. function isLoading(state:Boolean)
  86. {
  87.         status.text = state ? "Calling server-side service method to determine the result..." : "Tada! Wasn't that fun? Why not try two other numbers? Fun for all ages!";
  88.         sum.text = "";
  89.         progressIndicator._visible = state;
  90.         addButton.enabled = !state;
  91.         addButton._alpha = state ? 40:100;
  92. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post