// Copyright 2007. Adobe Systems Incorporated. All Rights Reserved.
package fl.controls {
import fl.controls.BaseButton;
import fl.controls.ButtonLabelPlacement;
import fl.controls.TextInput; //Only for ASDocs
import fl.core.InvalidationType;
import fl.core.UIComponent;
import fl.events.ComponentEvent;
import fl.managers.IFocusManagerComponent;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.geom.Point;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.ui.Keyboard;
//--------------------------------------
// Events
//--------------------------------------
/**
* Dispatched after the toggle button receives input from
* a mouse device or from the spacebar.
*
* @eventType flash.events.MouseEvent.CLICK
*
* @includeExample examples/student_ar_fl_controls_LabelButton.click.1.as -noswf
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Event(name="click", type="flash.events.MouseEvent")]
/**
* Dispatched after the label value changes.
*
* @eventType fl.events.ComponentEvent.LABEL_CHANGE
*
* @includeExample examples/student_ar_fl_controls_LabelButton.labelChange.1.as -noswf
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Event(name="labelChange", type="fl.events.ComponentEvent")]
//--------------------------------------
// Styles
//--------------------------------------
/**
* Name of the class to use as the skin for the background and border
* when the button is not selected and is disabled.
*
* @default Button_disabledSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="disabledSkin", type="Class")]
/**
* Name of the class to use as the skin for the background and border
* when the button is not selected and the mouse is not over the component.
*
* @default Button_upSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="upSkin", type="Class")]
/**
* Name of the class to use as the skin for the background and border
* when the button is not selected and the mouse button is down.
*
* @default Button_downSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="downSkin", type="Class")]
/**
* Name of the class to use as the skin for the background and border
* when the button is not selected and the mouse is over the component.
*
* @default Button_overSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="overSkin", type="Class")]
/**
* Name of the class to use as the skin for the background and border
* when a toggle button is selected and disabled.
*
* @default Button_selectedDisabledSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="selectedDisabledSkin", type="Class")]
/**
* Name of the class to use as the skin for the background and border
* when a toggle button is selected and the mouse is not over the component.
*
* @default Button_selectedUpSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="selectedUpSkin", type="Class")]
/**
* Name of the class to use as the skin for the background and border
* when a toggle button is selected and the mouse button is down.
*
* @default Button_selectedDownSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="selectedDownSkin", type="Class")]
/**
* Name of the class to use as the skin for the background and border
* when a toggle button is selected and the mouse is over the component.
*
* @default Button_selectedOverSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="selectedOverSkin", type="Class")]
/**
* The spacing between the text and the edges of the component, and the
* spacing between the text and the icon, in pixels.
*
* @default 5
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="textPadding", type="Number", format="Length")]
/**
* @copy fl.controls.BaseButton#style:repeatDelay
*
* @default 500
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="repeatDelay", type="Number", format="Time")]
/**
* @copy fl.controls.BaseButton#style:repeatInterval
*
* @default 35
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="repeatInterval", type="Number", format="Time")]
/**
* Name of the class to use as the icon when a toggle button is not selected
* and the mouse is not over the button.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="icon", type="Class")]
/**
* Name of the class to use as the icon when a toggle button is not selected and the mouse is not over the button.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="upIcon", type="Class")]
/**
* Name of the class to use as the icon when the button is not selected and the mouse button is down.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="downIcon", type="Class")]
/**
* Name of the class to use as the icon when the button is not selected and the mouse is over the component.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="overIcon", type="Class")]
/**
* Name of the class to use as the icon when the button is not disabled.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="disabledIcon", type="Class")]
/**
* Name of the class to use as the icon when the button is selected and disabled.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="selectedDisabledIcon", type="Class")]
/**
* Name of the class to use as the icon when the button is selected and the mouse button is up.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="selectedUpIcon", type="Class")]
/**
* Name of the class to use as the icon when the button is selected and the mouse button is down.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="selectedDownIcon", type="Class")]
/**
* Name of the class to use as the icon when the button is selected and the mouse is over the component.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="selectedOverIcon", type="Class")]
/**
* Indicates whether embedded font outlines are used to render the text field.
* If this value is true
, Flash Player renders the text field
* by using embedded font outlines. If this value is false
,
* Flash Player renders the text field by using device fonts.
*
*
If you set the embedFonts
property to true
* for a text field, you must specify a font for that text by using the
* font
property of a TextFormat object that is applied to the text field.
* If the specified font is not embedded in the SWF file, the text is not displayed.
The student_ar_fl_controls_LabelButton component is used as a simple button class that can be * combined with custom skin states that support ScrollBar buttons, NumericStepper * buttons, ColorPicker swatches, and so on.
* * @includeExample examples/student_ar_fl_controls_LabelButtonExample.as -noswf * @includeExample examples/IconWithToolTip.as * * @see fl.controls.BaseButton * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public class student_ar_fl_controls_LabelButton extends BaseButton implements IFocusManagerComponent { /** * A reference to the component's internal text field. * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public var textField:TextField; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _labelPlacement:String = ButtonLabelPlacement.RIGHT; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _toggle:Boolean = false; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var icon:DisplayObject; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var oldMouseState:String; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _label:String = "Label"; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var mode:String = "center"; // other option is "border". Not currently used, but is reference in subclasses. /** * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ private static var defaultStyles:Object = { icon:null, upIcon:null,downIcon:null,overIcon:null,disabledIcon:null, selectedDisabledIcon:null,selectedUpIcon:null,selectedDownIcon:null,selectedOverIcon:null, textFormat:null, disabledTextFormat:null, textPadding:5, embedFonts:false }; /** * @copy fl.core.UIComponent#getStyleDefinition() * * @includeExample ../core/examples/UIComponent.getStyleDefinition.1.as -noswf * * @see fl.core.UIComponent#getStyle() * @see fl.core.UIComponent#setStyle() * @see fl.managers.StyleManager * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public static function getStyleDefinition():Object { return mergeStyles(defaultStyles, BaseButton.getStyleDefinition()); } /** * @private * Method for creating the Accessibility class. * This method is called from UIComponent. * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public static var createAccessibilityImplementation:Function; /** * Creates a new student_ar_fl_controls_LabelButton component instance. * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function student_ar_fl_controls_LabelButton() { super(); } [Inspectable(defaultValue="Label")] /** * Gets or sets the text label for the component. By default, the label * text appears centered on the button. * *Note: Setting this property triggers the labelChange
* event object to be dispatched.
In ActionScript, you can use the following constants to set this property:
* *ButtonLabelPlacement.RIGHT
ButtonLabelPlacement.LEFT
ButtonLabelPlacement.BOTTOM
ButtonLabelPlacement.TOP
true
indicates that it
* can; a value of false
indicates that it cannot.
*
* If this value is true
, clicking the button
* toggles it between selected and unselected states. You can get
* or set this state programmatically by using the selected
* property.
If this value is false
, the button does not
* stay pressed after the user releases it. In this case, its
* selected
property is always false
.
Note: When the toggle
is set to false
,
* selected
is forced to false
because only
* toggle buttons can be selected.
true
indicates that it is
* toggled in the on position; a value of false
indicates
* that it is toggled in the off position. This property can be
* set only if the toggle
property is set to true
.
*
* For a CheckBox component, this value indicates whether the box * displays a check mark. For a RadioButton component, this value * indicates whether the component is selected.
* *The user can change this property by clicking the component, * but you can also set this property programmatically.
* *If the toggle
property is set to true
,
* changing this property also dispatches a change
event.