/FD3/FlashDevelop/Bin/Debug/Library/AS3/frameworks/FlashIDE/fl/controls/BaseButton.as

https://bitbucket.org/kkszysiu/flashdevelop · ActionScript · 174 lines · 53 code · 4 blank · 117 comment · 0 complexity · cbd33522854e490eceb3505208001861 MD5 · raw file

  1. package fl.controls
  2. {
  3. import fl.core.InvalidationType;
  4. import fl.core.UIComponent;
  5. import fl.events.ComponentEvent;
  6. import flash.display.DisplayObject;
  7. import flash.display.Sprite;
  8. import flash.events.Event;
  9. import flash.events.MouseEvent;
  10. import flash.events.TimerEvent;
  11. import flash.utils.Timer;
  12. /**
  13. * Dispatched when the user presses the Button component. * If the <code>autoRepeat</code> property is <code>true</code>, * this event is dispatched at specified intervals until the * button is released. * * <p>The <code>repeatDelay</code> style is used to * specify the delay before the <code>buttonDown</code> event is * dispatched a second time. The <code>repeatInterval</code> style * specifies the interval at which this event is dispatched thereafter, * until the user releases the button.</p> * * @eventType fl.events.ComponentEvent.BUTTON_DOWN * * @includeExample examples/BaseButton.autoRepeat.1.as -noswf * * @see #autoRepeat * @see #style:repeatDelay style * @see #style:repeatInterval style * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  14. */
  15. [Event(name="buttonDown", type="fl.events.ComponentEvent")]
  16. /**
  17. * Dispatched when the value of the <code>selected</code> property * of a toggle Button component changes. A toggle Button component is a * Button component whose <code>toggle</code> property is set to <code>true</code>. * * <p>The CheckBox and RadioButton components dispatch this event after * there is a change in the <code>selected</code> property.</p> * * @eventType flash.events.Event.CHANGE * * @includeExample examples/LabelButton.toggle.1.as -noswf * * @see #selected selected * @see LabelButton#toggle LabelButton.toggle * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  18. */
  19. [Event(name="change", type="flash.events.Event")]
  20. /**
  21. * @copy fl.controls.LabelButton#style:upSkin * * @default Button_upSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  22. */
  23. [Style(name="upSkin", type="Class")]
  24. /**
  25. * @copy fl.controls.LabelButton#style:downSkin * * @default Button_downSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  26. */
  27. [Style(name="downSkin", type="Class")]
  28. /**
  29. * @copy fl.controls.LabelButton#style:overSkin * * @default Button_overSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  30. */
  31. [Style(name="overSkin", type="Class")]
  32. /**
  33. * @copy fl.controls.LabelButton#style:disabledSkin * * @default Button_disabledSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  34. */
  35. [Style(name="disabledSkin", type="Class")]
  36. /**
  37. * @copy fl.controls.LabelButton#style:selectedDisabledSkin * * @default Button_selectedDisabledSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  38. */
  39. [Style(name="selectedDisabledSkin", type="Class")]
  40. /**
  41. * @copy fl.controls.LabelButton#style:selectedUpSkin * * @default Button_selectedUpSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  42. */
  43. [Style(name="selectedUpSkin", type="Class")]
  44. /**
  45. * @copy fl.controls.LabelButton#style:selectedDownSkin * * @default Button_selectedDownSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  46. */
  47. [Style(name="selectedDownSkin", type="Class")]
  48. /**
  49. * @copy fl.controls.LabelButton#style:selectedOverSkin * * @default Button_selectedOverSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  50. */
  51. [Style(name="selectedOverSkin", type="Class")]
  52. /**
  53. * The number of milliseconds to wait after the <code>buttonDown</code> * event is first dispatched before sending a second <code>buttonDown</code> * event. * * @default 500 * * @see #event:buttonDown * @see #autoRepeat * @see #style:repeatInterval * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  54. */
  55. [Style(name="repeatDelay", type="Number", format="Time")]
  56. /**
  57. * The interval, in milliseconds, between <code>buttonDown</code> events * that are dispatched after the delay that is specified by the <code>repeatDelay</code> * style. * * @default 35 * * @see #event:buttonDown * @see #autoRepeat * @see #style:repeatDelay * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  58. */
  59. [Style(name="repeatInterval", type="Number", format="Time")]
  60. /**
  61. * The BaseButton class is the base class for all button components, defining * properties and methods that are common to all buttons. This class handles * drawing states and the dispatching of button events. * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  62. */
  63. public class BaseButton extends UIComponent
  64. {
  65. /**
  66. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  67. */
  68. protected var background : DisplayObject;
  69. /**
  70. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  71. */
  72. protected var mouseState : String;
  73. /**
  74. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  75. */
  76. protected var _selected : Boolean;
  77. /**
  78. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  79. */
  80. protected var _autoRepeat : Boolean;
  81. /**
  82. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  83. */
  84. protected var pressTimer : Timer;
  85. /**
  86. * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  87. */
  88. private var _mouseStateLocked : Boolean;
  89. /**
  90. * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  91. */
  92. private var unlockedMouseState : String;
  93. /**
  94. * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  95. */
  96. private static var defaultStyles : Object;
  97. /**
  98. * Gets or sets a value that indicates whether the component can accept user * input. A value of <code>true</code> indicates that the component can accept * user input; a value of <code>false</code> indicates that it cannot. * * <p>When this property is set to <code>false</code>, the button is disabled. * This means that although it is visible, it cannot be clicked. This property is * useful for disabling a specific part of the user interface. For example, a button * that is used to trigger the reloading of a web page could be disabled * by using this technique.</p> * * @default true * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  99. */
  100. public function get enabled () : Boolean;
  101. /**
  102. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  103. */
  104. public function set enabled (value:Boolean) : void;
  105. /**
  106. * Gets or sets a Boolean value that indicates whether a toggle button * is selected. A value of <code>true</code> indicates that the button is * selected; a value of <code>false</code> indicates that it is not. * This property has no effect if the <code>toggle</code> property * is not set to <code>true</code>. * * <p>For a CheckBox component, this value indicates whether the box is * checked. For a RadioButton component, this value indicates whether the * component is selected.</p> * * <p>This value changes when the user clicks the component * but can also be changed programmatically. If the <code>toggle</code> * property is set to <code>true</code>, changing this property causes * a <code>change</code> event object to be dispatched.</p> * * @default false * * @includeExample examples/LabelButton.toggle.1.as -noswf * * @see #event:change change * @see LabelButton#toggle LabelButton.toggle * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  107. */
  108. public function get selected () : Boolean;
  109. /**
  110. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  111. */
  112. public function set selected (value:Boolean) : void;
  113. /**
  114. * Gets or sets a Boolean value that indicates whether the <code>buttonDown</code> event * is dispatched more than one time when the user holds the mouse button down over the component. * A value of <code>true</code> indicates that the <code>buttonDown</code> event * is dispatched repeatedly while the mouse button remains down; a value of <code>false</code> * indicates that the event is dispatched only one time. * * <p>If this value is <code>true</code>, after the delay specified by the * <code>repeatDelay</code> style, the <code>buttonDown</code> * event is dispatched at the interval that is specified by the <code>repeatInterval</code> style.</p> * * @default false * * @includeExample examples/BaseButton.autoRepeat.1.as -noswf * * @see #style:repeatDelay * @see #style:repeatInterval * @see #event:buttonDown * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  115. */
  116. public function get autoRepeat () : Boolean;
  117. /**
  118. * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  119. */
  120. public function set autoRepeat (value:Boolean) : void;
  121. /**
  122. * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  123. */
  124. public function set mouseStateLocked (value:Boolean) : void;
  125. /**
  126. * @copy fl.core.UIComponent#getStyleDefinition() * * @includeExample ../core/examples/UIComponent.getStyleDefinition.1.as -noswf * * @see fl.core.UIComponent#getStyle() UIComponent.getStyle() * @see fl.core.UIComponent#setStyle() UIComponent.setStyle() * @see fl.managers.StyleManager StyleManager * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  127. */
  128. public static function getStyleDefinition () : Object;
  129. /**
  130. * Creates a new BaseButton instance. * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  131. */
  132. public function BaseButton ();
  133. /**
  134. * Set the mouse state via ActionScript. The BaseButton class * uses this property internally, but it can also be invoked manually, * and will set the mouse state visually. * * @param state A string that specifies a mouse state. Supported values are * "up", "over", and "down". * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  135. */
  136. public function setMouseState (state:String) : void;
  137. /**
  138. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  139. */
  140. protected function setupMouseEvents () : void;
  141. /**
  142. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  143. */
  144. protected function mouseEventHandler (event:MouseEvent) : void;
  145. /**
  146. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  147. */
  148. protected function startPress () : void;
  149. /**
  150. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  151. */
  152. protected function buttonDown (event:TimerEvent) : void;
  153. /**
  154. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  155. */
  156. protected function endPress () : void;
  157. /**
  158. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  159. */
  160. protected function draw () : void;
  161. /**
  162. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  163. */
  164. protected function drawBackground () : void;
  165. /**
  166. * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0
  167. */
  168. protected function drawLayout () : void;
  169. }
  170. }