/AdobeAIRSDK/frameworks/projects/framework/src/mx/core/FlexSprite.as

https://github.com/kibiz0r/FlashRuby
ActionScript | 113 lines | 24 code | 9 blank | 80 comment | 0 complexity | e9fc85df8f8ef129b89d347ef98777c0 MD5 | raw file
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // ADOBE SYSTEMS INCORPORATED
  4. // Copyright 2006 Adobe Systems Incorporated
  5. // All Rights Reserved.
  6. //
  7. // NOTICE: Adobe permits you to use, modify, and distribute this file
  8. // in accordance with the terms of the license agreement accompanying it.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. package mx.core
  12. {
  13. import flash.display.Sprite;
  14. import mx.utils.NameUtil;
  15. /**
  16. * FlexSprite is a subclass of the Player's Sprite class
  17. * and the superclass of UIComponent.
  18. * It overrides the <code>toString()</code> method
  19. * to return a string indicating the location of the object
  20. * within the hierarchy of DisplayObjects in the application.
  21. *
  22. * @langversion 3.0
  23. * @playerversion Flash 9
  24. * @playerversion AIR 1.1
  25. * @productversion Flex 3
  26. */
  27. public class FlexSprite extends Sprite
  28. {
  29. include "../core/Version.as";
  30. //--------------------------------------------------------------------------
  31. //
  32. // Constructor
  33. //
  34. //--------------------------------------------------------------------------
  35. /**
  36. * Constructor.
  37. *
  38. * <p>Sets the <code>name</code> property to a string
  39. * returned by the <code>createUniqueName()</code>
  40. * method of the mx.utils.NameUtils class.</p>
  41. *
  42. * <p>This string is the name of the object's class concatenated
  43. * with an integer that is unique within the application,
  44. * such as <code>"Button17"</code>.</p>
  45. *
  46. * @see flash.display.DisplayObject#name
  47. * @see mx.utils.NameUtil#createUniqueName()
  48. *
  49. * @langversion 3.0
  50. * @playerversion Flash 9
  51. * @playerversion AIR 1.1
  52. * @productversion Flex 3
  53. */
  54. public function FlexSprite()
  55. {
  56. super();
  57. try
  58. {
  59. name = NameUtil.createUniqueName(this);
  60. }
  61. catch(e:Error)
  62. {
  63. // The name assignment above can cause the RTE
  64. // Error #2078: The name property of a Timeline-placed
  65. // object cannot be modified.
  66. // if this class has been associated with an asset
  67. // that was created in the Flash authoring tool.
  68. // The only known case where this is a problem is when
  69. // an asset has another asset PlaceObject'd onto it and
  70. // both are embedded separately into a Flex application.
  71. // In this case, we ignore the error and toString() will
  72. // use the name assigned in the Flash authoring tool.
  73. }
  74. }
  75. //--------------------------------------------------------------------------
  76. //
  77. // Overridden methods
  78. //
  79. //--------------------------------------------------------------------------
  80. /**
  81. * Returns a string indicating the location of this object
  82. * within the hierarchy of DisplayObjects in the Application.
  83. * This string, such as <code>"MyApp0.HBox5.Button17"</code>,
  84. * is built by the <code>displayObjectToString()</code> method
  85. * of the mx.utils.NameUtils class from the <code>name</code>
  86. * property of the object and its ancestors.
  87. *
  88. * @return A String indicating the location of this object
  89. * within the DisplayObject hierarchy.
  90. *
  91. * @see flash.display.DisplayObject#name
  92. * @see mx.utils.NameUtil#displayObjectToString()
  93. *
  94. * @langversion 3.0
  95. * @playerversion Flash 9
  96. * @playerversion AIR 1.1
  97. * @productversion Flex 3
  98. */
  99. override public function toString():String
  100. {
  101. return NameUtil.displayObjectToString(this);
  102. }
  103. }
  104. }