// Copyright 2007. Adobe Systems Incorporated. All Rights Reserved.
package fl.controls {
import fl.core.InvalidationType;
import fl.core.UIComponent;
import fl.events.ComponentEvent;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
//--------------------------------------
// Events
//--------------------------------------
/**
* Dispatched when the user presses the Button component.
* If the autoRepeat
property is true
,
* this event is dispatched at specified intervals until the
* button is released.
*
*
The repeatDelay
style is used to
* specify the delay before the buttonDown
event is
* dispatched a second time. The repeatInterval
style
* specifies the interval at which this event is dispatched thereafter,
* until the user releases the button.
selected
property
* of a toggle Button component changes. A toggle Button component is a
* Button component whose toggle
property is set to true
.
*
* The CheckBox and RadioButton components dispatch this event after
* there is a change in the selected
property.
buttonDown
* event is first dispatched before sending a second buttonDown
* event.
*
* @default 500
*
* @see #event:buttonDown
* @see #autoRepeat
* @see #style:repeatInterval
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="repeatDelay", type="Number", format="Time")]
/**
* The interval, in milliseconds, between buttonDown
events
* that are dispatched after the delay that is specified by the repeatDelay
* style.
*
* @default 35
*
* @see #event:buttonDown
* @see #autoRepeat
* @see #style:repeatDelay
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="repeatInterval", type="Number", format="Time")]
//--------------------------------------
// Class description
//--------------------------------------
/**
* The student_ar_fl_controls_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
*/
public class student_ar_fl_controls_BaseButton extends UIComponent {
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var background:DisplayObject;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var mouseState:String;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _selected:Boolean = false;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _autoRepeat:Boolean = false;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var pressTimer:Timer;
/**
* @private
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
private var _mouseStateLocked:Boolean = false;
/**
* @private
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
private var unlockedMouseState:String;
/**
* @private
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
private static var defaultStyles:Object = {upSkin:"Button_upSkin",downSkin:"Button_downSkin",overSkin:"Button_overSkin",
disabledSkin:"Button_disabledSkin",
selectedDisabledSkin:"Button_selectedDisabledSkin",
selectedUpSkin:"Button_selectedUpSkin",selectedDownSkin:"Button_selectedDownSkin",selectedOverSkin:"Button_selectedOverSkin",
focusRectSkin:null, focusRectPadding:null,
repeatDelay:500,repeatInterval:35};
/**
* @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
*/
public static function getStyleDefinition():Object { return defaultStyles; }
//--------------------------------------
// Constructor
//--------------------------------------
/**
* Creates a new student_ar_fl_controls_BaseButton instance.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function student_ar_fl_controls_BaseButton() {
super();
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1,0);
pressTimer.addEventListener(TimerEvent.TIMER,buttonDown,false,0,true);
}
[Inspectable(defaultValue=true, verbose=1)]
/**
* Gets or sets a value that indicates whether the component can accept user
* input. A value of true
indicates that the component can accept
* user input; a value of false
indicates that it cannot.
*
* When this property is set to false
, 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.
true
indicates that the button is
* selected; a value of false
indicates that it is not.
* This property has no effect if the toggle
property
* is not set to true
.
*
* For a CheckBox component, this value indicates whether the box is * checked. For a RadioButton component, this value indicates whether the * component is selected.
* *This value changes when the user clicks the component
* but can also be changed programmatically. If the toggle
* property is set to true
, changing this property causes
* a change
event object to be dispatched.
buttonDown
event
* is dispatched more than one time when the user holds the mouse button down over the component.
* A value of true
indicates that the buttonDown
event
* is dispatched repeatedly while the mouse button remains down; a value of false
* indicates that the event is dispatched only one time.
*
* If this value is true
, after the delay specified by the
* repeatDelay
style, the buttonDown
* event is dispatched at the interval that is specified by the repeatInterval
style.