Private Paste: A Secure, Private, Encryptable Pastebin

Paste ID posted at 05/15/2008 09:03:02 AM GMT-8 - ActionScript formatting

Copy Content*Download Text Version

  1. /*
  2.  
  3. How to Retrieve The URL For Your Running Flex Application
  4.  
  5. http://userflex.wordpress.com/2008/05/15/running-app-url/
  6.  
  7. */
  8. package com.userflex.sample.util
  9. {
  10. // import statements
  11. import flash.external.ExternalInterface;
  12.  
  13.  
  14. /**
  15. * The JSUtil class is an all-static class with methods for accessing
  16. * JavaScript values using ExternalInterface. You do not create
  17. * instances of JSUtil; instead you simply call static methods such as
  18. * the JSUtil.getWindowLocation() method.
  19. */
  20. public class JSUtil
  21. {
  22. /**
  23. * Returns the current application URL.
  24. *
  25. * @return the current application URL
  26. */
  27. public static function getWindowLocation () : String
  28. {
  29. var location : String = null;
  30.  
  31. // checks if external interface is available
  32. if (ExternalInterface.available)
  33. {
  34. try
  35. {
  36. location = ExternalInterface.call
  37. ("window.location.href.toString");
  38. }
  39. catch (error : Error)
  40. {
  41. location = null;
  42. }
  43. }
  44.  
  45. return location;
  46. }
  47.  
  48. }
  49. }
  50.  

Copy Content*Download Text Version

* Copy Content will display a textarea with the content and attempt to copy it to your clipboard.