All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scaffold.libs_as.feathers.controls.Radio.as Maven / Gradle / Ivy

/*
Feathers
Copyright 2012-2015 Bowler Hat LLC. All Rights Reserved.

This program is free software. You can redistribute and/or modify it in
accordance with the terms of the accompanying license agreement.
*/
package feathers.controls
{
	import feathers.core.IGroupedToggle;
	import feathers.core.ToggleGroup;
	import feathers.skins.IStyleProvider;

	import flash.errors.IllegalOperationError;

	import starling.events.Event;

	[Exclude(name="isToggle",kind="property")]

	/**
	 * A toggleable control that exists in a set that requires a single,
	 * exclusive toggled item.
	 *
	 * 

In the following example, a set of radios are created, along with a * toggle group to group them together:

* * * var group:ToggleGroup = new ToggleGroup(); * group.addEventListener( Event.CHANGE, group_changeHandler ); * * var radio1:Radio = new Radio(); * radio1.label = "One"; * radio1.toggleGroup = group; * this.addChild( radio1 ); * * var radio2:Radio = new Radio(); * radio2.label = "Two"; * radio2.toggleGroup = group; * this.addChild( radio2 ); * * var radio3:Radio = new Radio(); * radio3.label = "Three"; * radio3.toggleGroup = group; * this.addChild( radio3 ); * * @see ../../../help/radio.html How to use the Feathers Radio component * @see feathers.core.ToggleGroup */ public class Radio extends ToggleButton implements IGroupedToggle { /** * The default value added to the styleNameList of the label. * * @see feathers.core.FeathersControl#styleNameList */ public static const DEFAULT_CHILD_STYLE_NAME_LABEL:String = "feathers-radio-label"; /** * @private * DEPRECATED: Replaced by feathers.controls.ButtonState.UP. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const STATE_UP:String = "up"; /** * @private * DEPRECATED: Replaced by feathers.controls.ButtonState.DOWN. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const STATE_DOWN:String = "down"; /** * @private * DEPRECATED: Replaced by feathers.controls.ButtonState.HOVER. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const STATE_HOVER:String = "hover"; /** * @private * DEPRECATED: Replaced by feathers.controls.ButtonState.DISABLED. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const STATE_DISABLED:String = "disabled"; /** * @private * DEPRECATED: Replaced by feathers.controls.ButtonState.UP_AND_SELECTED. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const STATE_UP_AND_SELECTED:String = "upAndSelected"; /** * @private * DEPRECATED: Replaced by feathers.controls.ButtonState.DOWN_AND_SELECTED. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const STATE_DOWN_AND_SELECTED:String = "downAndSelected"; /** * @private * DEPRECATED: Replaced by feathers.controls.ButtonState.HOVER_AND_SELECTED. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const STATE_HOVER_AND_SELECTED:String = "hoverAndSelected"; /** * @private * DEPRECATED: Replaced by feathers.controls.ButtonState.DISABLED_AND_SELECTED. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const STATE_DISABLED_AND_SELECTED:String = "disabledAndSelected"; /** * @private * DEPRECATED: Replaced by feathers.layout.RelativePosition.TOP. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const ICON_POSITION_TOP:String = "top"; /** * @private * DEPRECATED: Replaced by feathers.layout.RelativePosition.RIGHT. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const ICON_POSITION_RIGHT:String = "right"; /** * @private * DEPRECATED: Replaced by feathers.layout.RelativePosition.BOTTOM. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const ICON_POSITION_BOTTOM:String = "bottom"; /** * @private * DEPRECATED: Replaced by feathers.layout.RelativePosition.LEFT. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const ICON_POSITION_LEFT:String = "left"; /** * @private * DEPRECATED: Replaced by feathers.layout.RelativePosition.MANUAL. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const ICON_POSITION_MANUAL:String = "manual"; /** * @private * DEPRECATED: Replaced by feathers.layout.RelativePosition.LEFT_BASELINE. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const ICON_POSITION_LEFT_BASELINE:String = "leftBaseline"; /** * @private * DEPRECATED: Replaced by feathers.layout.RelativePosition.RIGHT_BASELINE. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const ICON_POSITION_RIGHT_BASELINE:String = "rightBaseline"; /** * @private * DEPRECATED: Replaced by feathers.layout.HorizontalAlign.LEFT. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const HORIZONTAL_ALIGN_LEFT:String = "left"; /** * @private * DEPRECATED: Replaced by feathers.layout.HorizontalAlign.CENTER. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const HORIZONTAL_ALIGN_CENTER:String = "center"; /** * @private * DEPRECATED: Replaced by feathers.layout.HorizontalAlign.RIGHT. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const HORIZONTAL_ALIGN_RIGHT:String = "right"; /** * @private * DEPRECATED: Replaced by feathers.layout.VerticalAlign.TOP. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const VERTICAL_ALIGN_TOP:String = "top"; /** * @private * DEPRECATED: Replaced by feathers.layout.VerticalAlign.MIDDLE. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const VERTICAL_ALIGN_MIDDLE:String = "middle"; /** * @private * DEPRECATED: Replaced by feathers.layout.VerticalAlign.BOTTOM. * *

DEPRECATION WARNING: This constant is deprecated * starting with Feathers 3.0. It will be removed in a future version of * Feathers according to the standard * Feathers deprecation policy.

*/ public static const VERTICAL_ALIGN_BOTTOM:String = "bottom"; /** * If a Radio has not been added to a ToggleGroup, * it will automatically be added to this group. If the Radio's * toggleGroup property is set to a different group, it * will be automatically removed from this group, if required. */ public static const defaultRadioGroup:ToggleGroup = new ToggleGroup(); /** * The default IStyleProvider for all Radio * components. * * @default null * @see feathers.core.FeathersControl#styleProvider */ public static var globalStyleProvider:IStyleProvider; /** * Constructor. */ public function Radio() { super(); super.isToggle = true; this.labelStyleName = DEFAULT_CHILD_STYLE_NAME_LABEL; this.addEventListener(Event.ADDED_TO_STAGE, radio_addedToStageHandler); this.addEventListener(Event.REMOVED_FROM_STAGE, radio_removedFromStageHandler); } /** * @private */ override protected function get defaultStyleProvider():IStyleProvider { return Radio.globalStyleProvider; } /** * @private */ override public function set isToggle(value:Boolean):void { throw IllegalOperationError("Radio isToggle must always be true."); } /** * @private */ override public function set toggleGroup(value:ToggleGroup):void { if(this._toggleGroup === value) { return; } //a null toggle group will automatically add it to //defaultRadioGroup. however, if toggleGroup is already //defaultRadioGroup, then we really want to use null because //otherwise we'd remove the radio from defaultRadioGroup and then //immediately add it back because ToggleGroup sets the toggleGroup //property to null when removing an item. if(!value && this._toggleGroup !== defaultRadioGroup && this.stage) { value = defaultRadioGroup; } super.toggleGroup = value; } /** * @private */ protected function radio_addedToStageHandler(event:Event):void { if(!this._toggleGroup) { this.toggleGroup = defaultRadioGroup; } } /** * @private */ protected function radio_removedFromStageHandler(event:Event):void { if(this._toggleGroup == defaultRadioGroup) { this._toggleGroup.removeItem(this); } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy