first commit
This commit is contained in:
		
							
								
								
									
										154
									
								
								com/yahoo/astra/fl/controls/containerClasses/AutoSizeButton.as
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										154
									
								
								com/yahoo/astra/fl/controls/containerClasses/AutoSizeButton.as
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,154 @@ | ||||
| /* | ||||
| Copyright (c) 2009 Yahoo! Inc.  All rights reserved.   | ||||
| The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license | ||||
| */ | ||||
| package com.yahoo.astra.fl.controls.containerClasses | ||||
| { | ||||
| 	import fl.controls.Button; | ||||
| 	import flash.text.TextFieldAutoSize; | ||||
| 	import fl.events.ComponentEvent; | ||||
| 	import fl.core.UIComponent; | ||||
| 	import flash.text.TextFormat; | ||||
| 	import fl.core.InvalidationType; | ||||
| 	import flash.display.DisplayObject; | ||||
| 	import com.yahoo.astra.fl.utils.UIComponentUtil; | ||||
| 	import com.yahoo.astra.utils.InstanceFactory; | ||||
| 	//-------------------------------------- | ||||
| 	//  Class description | ||||
| 	//-------------------------------------- | ||||
|  | ||||
| 	/**	 | ||||
| 	 * AutoSizeButton extends Button and create a button that sizes itself based on the | ||||
| 	 * size of its label and fires a change event when the button is resized. | ||||
| 	 * | ||||
| 	 * @see fl.controls.Button | ||||
| 	 * | ||||
| 	 * | ||||
| 	 * @langversion 3.0 | ||||
| 	 * @playerversion Flash 9.0.28.0 | ||||
| 	 */ | ||||
| 	public class AutoSizeButton extends Button | ||||
| 	{ | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Constructor | ||||
| 	//-------------------------------------- | ||||
| 	 | ||||
| 		/** | ||||
| 		 * Constructor | ||||
| 		 */ | ||||
| 		public function AutoSizeButton() | ||||
| 		{ | ||||
| 			super(); | ||||
| 		}		 | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Properties | ||||
| 	//-------------------------------------- | ||||
| 	 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 */ | ||||
| 		private static var defaultStyles:Object = | ||||
| 		{ | ||||
| 			focusRectPadding: 1, | ||||
| 			icon: null, | ||||
| 			upSkin: "Button_upSkin", | ||||
| 			downSkin: "Button_downSkin", | ||||
| 			overSkin: "Button_overSkin", | ||||
| 			disabledSkin: "Button_disabledSkin", | ||||
| 			selectedUpSkin: "Button_selectedUpSkin", | ||||
| 			selectedDownSkin: "Button_selectedUpSkin", | ||||
| 			selectedOverSkin: "Button_selectedUpSkin", | ||||
| 			selectedDisabledSkin: "Button_selectedDisabledSkin", | ||||
| 			focusRectSkin: "focusRectSkin", | ||||
| 			textPadding: 10, | ||||
| 			verticalTextPadding: 2, | ||||
| 			textFormat:null,  | ||||
| 			disabledTextFormat:null, | ||||
| 			embedFonts:false			 | ||||
| 		};	 | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 * This component will resize based on the size of its label. | ||||
| 		 */ | ||||
| 		override public function set label(value:String):void | ||||
| 		{ | ||||
| 			this._label = value; | ||||
| 		} | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Public Methods | ||||
| 	//--------------------------------------		 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @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 defaultStyles; | ||||
| 		} | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Protected Methods | ||||
| 	//--------------------------------------			 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//We're going to resize based on the size of the label, rather than the avatar  | ||||
| 		override protected function configUI():void | ||||
| 		{ | ||||
| 			super.configUI(); | ||||
| 			this.textField.autoSize = TextFieldAutoSize.LEFT; | ||||
| 			this.setStyle("focusRectPadding", getStyleDefinition().focusRectPadding); | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		override protected function draw():void | ||||
| 		{ | ||||
| 			if(this.textField.text != this._label) | ||||
| 			{ | ||||
| 				this.textField.text = this._label; | ||||
| 				this.width = this.textField.width + (this.getStyleValue("textPadding") as Number) * 2; | ||||
| 				this.dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE)); | ||||
| 			} | ||||
| 			super.draw(); | ||||
| 			this.drawFocus(isFocused); | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @copy fl.core.UIComponent#setStyle | ||||
| 		 * @langversion 3.0 | ||||
| 		 * @playerversion Flash 9.0.28.0		  | ||||
| 		 */ | ||||
| 		override public function setStyle(style:String, value:Object):void { | ||||
| 			//Use strict equality so we can set a style to null ... so if the instanceStyles[style] == undefined, null is still set. | ||||
| 			//We also need to work around the specific use case of TextFormats | ||||
| 			if (instanceStyles[style] === value && !(value is TextFormat)) { return; } | ||||
| 			if(value is InstanceFactory)  | ||||
| 			{ | ||||
| 				instanceStyles[style] = UIComponentUtil.getDisplayObjectInstance(this, (value as InstanceFactory).createInstance()); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				instanceStyles[style] = value; | ||||
| 			} | ||||
| 			invalidate(InvalidationType.STYLES); | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										452
									
								
								com/yahoo/astra/fl/controls/containerClasses/ButtonBar.as
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										452
									
								
								com/yahoo/astra/fl/controls/containerClasses/ButtonBar.as
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,452 @@ | ||||
| /* | ||||
| Copyright (c) 2009 Yahoo! Inc.  All rights reserved.   | ||||
| The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license | ||||
| */ | ||||
| package com.yahoo.astra.fl.controls.containerClasses | ||||
| { | ||||
| 	import com.yahoo.astra.fl.controls.containerClasses.AutoSizeButton; | ||||
| 	import fl.events.ComponentEvent; | ||||
| 	import flash.events.MouseEvent; | ||||
| 	import fl.core.UIComponent; | ||||
| 	import flash.events.KeyboardEvent; | ||||
| 	import flash.events.FocusEvent; | ||||
| 	import flash.ui.Keyboard; | ||||
| 	import flash.text.TextFormat; | ||||
| 	import com.yahoo.astra.utils.InstanceFactory; | ||||
| 	import com.yahoo.astra.fl.utils.UIComponentUtil; | ||||
| 	 | ||||
| 	//-------------------------------------- | ||||
| 	//  Class description | ||||
| 	//-------------------------------------- | ||||
|  | ||||
| 	/** | ||||
| 	 * ButtonBar extends UIComponent and builds one or multiple rows of AutoSizeButton | ||||
| 	 * instances depending on the dimensions of its parent container and the size of the  | ||||
| 	 * buttons | ||||
| 	 * | ||||
| 	 * @see fl.core.UIComponent | ||||
| 	 * @see com.yahoo.astra.fl.controls.containerClasses.AutoSizeButton | ||||
| 	 * | ||||
|      * @langversion 3.0 | ||||
|      * @playerversion Flash 9.0.28.0 | ||||
|      * @author Dwight Bridges	 | ||||
| 	 */		  | ||||
| 	public class ButtonBar extends UIComponent | ||||
| 	{ | ||||
|  | ||||
| 	//-------------------------------------- | ||||
| 	//  Constructor | ||||
| 	//-------------------------------------- | ||||
| 	 | ||||
| 		/** | ||||
| 		 * Constructor | ||||
| 		 */ | ||||
| 	 	public function ButtonBar() | ||||
| 	 	{ | ||||
| 			super(); | ||||
| 			this.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler); | ||||
| 			this.addEventListener(KeyboardEvent.KEY_DOWN, navigationKeyDownHandler); | ||||
| 			tabChildren = false;			 | ||||
| 		} | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Properties | ||||
| 	//--------------------------------------				 | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */  | ||||
| 		override public function set height(ht:Number):void {_height = ht;} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets or sets the width | ||||
| 		 */ | ||||
| 		override public function get width():Number {return _width;} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Contains an object for each button.  The object contains the button and an  | ||||
| 		//array of listeners attached to the button | ||||
| 		public var _buttons:Array = []; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
|  		 */ | ||||
| 		//array containing buttons that can be used when the drawButtons method is called | ||||
| 		private var _cachedButtons:Array = []; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Used to determine the x coordinate of buttons | ||||
| 		protected var _left:Number = 0; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */		 | ||||
| 		//holds index of the object to have focus | ||||
| 		protected var _focusIndex:int; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//the button that currently has focus | ||||
| 		protected var _focusButton:AutoSizeButton; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * The amount of padding between buttons | ||||
| 		 */ | ||||
| 		public var spacing:int; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * The amount of padding between rows | ||||
| 		 */ | ||||
| 		public var rowSpacing:int;		 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * The maximum width of the component.  Used to determine how many rows  | ||||
| 		 * of buttons are necessary. | ||||
| 		 */ | ||||
| 		public var maxWidth:int; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Number of buttons to be drawn.   | ||||
| 		protected var _length:uint; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Number of buttons loaded | ||||
| 		protected var _buttonsLoaded:uint; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Array containing index for each row of buttons | ||||
| 		protected var _rows:Array; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Current index for the button rows | ||||
| 		protected var _currentRow:uint; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets or sets the index of the button that has focus. | ||||
| 		 */ | ||||
| 		public function get focusIndex():int | ||||
| 		{ | ||||
| 			return _focusIndex; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */ | ||||
| 		public function set focusIndex(value:int):void | ||||
| 		{ | ||||
| 			_focusIndex = value; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 */ | ||||
| 		private var defaultButtonStyles:Object = {};  | ||||
| 	 	 | ||||
| 	//-------------------------------------- | ||||
| 	//  Public Methods | ||||
| 	//-------------------------------------- | ||||
|  | ||||
| 	 	/** | ||||
| 	 	 * Draws and arranges buttons | ||||
| 	 	 * | ||||
| 	 	 * @param labels - an array of strings to be used as the text for the buttons | ||||
| 	 	 * @param listeners - an array of handler functions to be called on a button click | ||||
| 	 	 */ | ||||
| 	 	public function drawButtons(labels:Array, listeners:Array):void | ||||
| 	 	{	 | ||||
| 			_currentRow = _buttonsLoaded = _left = _width = 0; | ||||
| 			_rows = []; | ||||
| 			_rows[_currentRow] = {}; | ||||
| 			_rows[_currentRow].buttons = []; | ||||
| 			_rows[_currentRow].width = 0; | ||||
| 			 | ||||
| 			this.removeChildren(); | ||||
| 			this.setFocus();			 | ||||
| 			_focusIndex = 0; | ||||
| 			var cachedLen:Number = _cachedButtons.length; | ||||
| 			var len:uint = _length = labels.length; | ||||
| 			for(var i:uint = 0; i < len; i++) | ||||
| 			{ | ||||
| 				var newButton:AutoSizeButton; | ||||
| 				var label:String = labels[i]; | ||||
| 				if(i < cachedLen) | ||||
| 				{ | ||||
| 					newButton = _cachedButtons[i];	 | ||||
| 					newButton.textField.text = ""; | ||||
| 					newButton.visible = true; | ||||
| 					newButton.label = newButton.name = label; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					newButton = new AutoSizeButton(); | ||||
| 					newButton.height = _height; | ||||
| 					this.addChild(newButton); | ||||
| 					newButton.addEventListener(ComponentEvent.LABEL_CHANGE, buttonChangeHandler); | ||||
| 					newButton.label = newButton.name = label; | ||||
| 					newButton.useHandCursor = true; | ||||
| 					_cachedButtons.push(newButton); | ||||
| 				} | ||||
| 				 | ||||
| 				var listlen:uint = listeners.length; | ||||
| 				for(var j:uint = 0; j < listlen; j++) | ||||
| 				{ | ||||
| 					newButton.addEventListener(MouseEvent.CLICK, listeners[j]); | ||||
| 				} | ||||
| 				 | ||||
| 				newButton.drawNow(); | ||||
| 				newButton.tabIndex = i+1; | ||||
| 				_buttons.push({button:newButton, listeners:listeners});	 | ||||
| 				 | ||||
| 			} | ||||
| 			this.setFocusButton(); | ||||
| 			this.setButtonStyles(); | ||||
| 	 	} | ||||
| 	 	 | ||||
| 		 | ||||
| 	 	/** | ||||
| 	 	 * Removes buttons | ||||
| 	 	 */ | ||||
| 	 	public function removeChildren():void | ||||
| 	 	{ | ||||
| 			_buttons.forEach(disableButtons); | ||||
| 			_buttons = []; | ||||
| 	 	} | ||||
| 	 	 | ||||
| 	 	/** | ||||
| 	 	 * Positions each button after it has been resized.  Creates multiple rows if a  | ||||
| 	 	 * single row of buttons will exceed the maximum width. | ||||
| 	 	 * | ||||
| 	 	 * @param evnt - event fired from buttons after it has been redrawn | ||||
| 	 	 * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */ | ||||
| 	 	public function buttonChangeHandler(evnt:ComponentEvent):void | ||||
| 	 	{ | ||||
| 			var thisButton:AutoSizeButton = evnt.target as AutoSizeButton; | ||||
| 			if(_left + thisButton.width <= maxWidth) | ||||
| 			{ | ||||
| 				thisButton.x = _left; | ||||
| 				_left += thisButton.width + spacing; | ||||
| 				_rows[_currentRow].width = _left - spacing; | ||||
| 				_rows[_currentRow].buttons.push(thisButton);				 | ||||
| 				_width = Math.max(_width, _rows[_currentRow].width); | ||||
| 				thisButton.y = (thisButton.height * _currentRow) + (rowSpacing * _currentRow); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				_left = thisButton.x = 0; | ||||
| 				_currentRow++; | ||||
| 				_rows[_currentRow] = {}; | ||||
| 				_rows[_currentRow].buttons = [];				 | ||||
| 				_rows[_currentRow].width = thisButton.width; | ||||
| 				_rows[_currentRow].buttons.push(thisButton);			 | ||||
| 				thisButton.y = (thisButton.height * _currentRow) + (rowSpacing * _currentRow); | ||||
| 				_width = Math.max(thisButton.width, _width); | ||||
| 				_left += thisButton.width + spacing; | ||||
| 			} | ||||
| 			_buttonsLoaded++; | ||||
| 			if(_buttonsLoaded == _length) | ||||
| 			{ | ||||
| 				var len:uint = _rows.length; | ||||
| 				if(len > 1) | ||||
| 				{ | ||||
| 					_rows.forEach(centerButtonRow); | ||||
| 					_height = thisButton.y + thisButton.height; | ||||
| 					this.dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE)); | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					this.dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE)); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 				 | ||||
| 		/* | ||||
| 		 * Sets the focus for the correct button. | ||||
| 		 * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */			 | ||||
| 		public function setFocusButton():void | ||||
| 		{ | ||||
| 			_focusButton = _buttons[_focusIndex].button;  | ||||
| 			_focusButton.setFocus(); | ||||
| 			_focusButton.drawFocus(true); | ||||
| 		} | ||||
| 		 | ||||
| 		/* | ||||
| 		 * Set the index to have focus and call the <code>setFocusButton</code> function | ||||
| 		 * | ||||
| 		 * @param decrem indicates whether to increase or decrease the focus index | ||||
| 		 * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */	 | ||||
| 		public function setFocusIndex(decrem:Boolean):void | ||||
| 		{ | ||||
| 			var len:int = _buttons.length - 1; | ||||
| 			if(decrem) | ||||
| 			{ | ||||
| 				if(_focusIndex == 0)  | ||||
| 				{ | ||||
| 					_focusIndex = len;	 | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					_focusIndex--; | ||||
| 				}					 | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				if(_focusIndex == len) | ||||
| 				{ | ||||
| 					_focusIndex = 0; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					_focusIndex++; | ||||
| 				}				 | ||||
| 			} | ||||
| 			setFocusButton(); | ||||
| 		}		 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Sets the styles of the buttons | ||||
| 		 */ | ||||
| 		public function setButtonStyle(name:String, style:Object):void | ||||
| 		{ | ||||
| 			defaultButtonStyles[name] = style; | ||||
| 			if(_buttons != null && _buttons.length > 0) | ||||
| 			{ | ||||
| 				for(var i:int = 0; i < _buttons.length; i++) | ||||
| 				{ | ||||
| 					(_buttons[i].button as UIComponent).setStyle(name, style); | ||||
| 				} | ||||
| 			}	 | ||||
| 		} | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Protected Methods | ||||
| 	//--------------------------------------		 | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */ | ||||
| 		//Adjusts the x coordinate for each button in a row | ||||
| 		//Called when there are multiple rows so that the buttons will be centered		  | ||||
| 		protected function centerButtonRow(element:*, index:Number, arr:Array):void | ||||
| 		{ | ||||
| 			var wid:uint = element.width; | ||||
| 			var buttons:Array = element.buttons; | ||||
| 			for(var i:uint = 0; i < buttons.length;i++) | ||||
| 			{ | ||||
| 				buttons[i].x += Math.round((_width - wid)/2); | ||||
| 			}			 | ||||
| 		} | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */ | ||||
| 		//Remove event listeners from each button | ||||
| 		//Set visibility to false for each button | ||||
| 		protected function disableButtons(element:*, index:Number, arr:Array):void  | ||||
| 		{ | ||||
| 			var button:AutoSizeButton = element.button; | ||||
| 			var listeners:Array = element.listeners; | ||||
| 			var len:uint = listeners.length; | ||||
| 			for(var i:uint = 0; i < len; i++) | ||||
| 			{ | ||||
| 				button.removeEventListener(MouseEvent.CLICK, listeners[i]); | ||||
| 			} | ||||
| 			button.visible = false; | ||||
| 		} | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */ | ||||
| 		//If the right arrow is pressed, pass a value of false to the setFocusIndex function | ||||
| 		//If the left arrow is pressed, pass a value of true to the setFocusIndex function | ||||
| 		//If the enter key is pressed, dispatch a click event from the _focusButton		  | ||||
| 		protected function navigationKeyDownHandler(evnt:KeyboardEvent):void | ||||
| 		{ | ||||
| 			switch(evnt.keyCode) | ||||
| 			{ | ||||
| 				case Keyboard.RIGHT :			 | ||||
| 					setFocusIndex(false); | ||||
| 				break; | ||||
| 				case Keyboard.LEFT : | ||||
| 					setFocusIndex(true); | ||||
| 				break;	 | ||||
| 				 | ||||
| 				case Keyboard.ENTER : | ||||
| 					_focusButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		/* | ||||
| 		 * @private (protected) | ||||
| 		 * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */		 | ||||
| 		//On the keyFocusChange event, prevent the default handling of the tab key  | ||||
| 		protected function keyFocusChangeHandler(evnt:FocusEvent):void | ||||
| 		{ | ||||
| 			if(evnt.keyCode == Keyboard.TAB) | ||||
| 			{ | ||||
| 				evnt.preventDefault(); | ||||
| 				setFocusIndex(evnt.shiftKey) | ||||
| 				 | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 * Copies button styles to a button | ||||
| 		 */ | ||||
| 		private function setButtonStyles():void | ||||
| 		{ | ||||
| 			var len:int = _buttons.length; | ||||
| 			for(var i:int = 0; i < len; i++) | ||||
| 			{ | ||||
| 				for(var n:String in defaultButtonStyles) | ||||
| 				{ | ||||
| 					(_buttons[i].button as UIComponent).setStyle(n, defaultButtonStyles[n]); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 */ | ||||
| 		override protected function draw():void | ||||
| 		{ | ||||
| 			setButtonStyles(); | ||||
| 		}		 | ||||
| 		  | ||||
| 	}	 | ||||
| } | ||||
							
								
								
									
										684
									
								
								com/yahoo/astra/fl/controls/containerClasses/DialogBox.as
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										684
									
								
								com/yahoo/astra/fl/controls/containerClasses/DialogBox.as
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,684 @@ | ||||
| /* | ||||
| Copyright (c) 2009 Yahoo! Inc.  All rights reserved.   | ||||
| The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license | ||||
| */ | ||||
| package com.yahoo.astra.fl.controls.containerClasses | ||||
| { | ||||
| 	import flash.text.*; | ||||
| 	import flash.display.Graphics; | ||||
| 	import flash.events.Event; | ||||
| 	import flash.events.MouseEvent; | ||||
| 	import flash.display.DisplayObject; | ||||
| 	import flash.display.DisplayObjectContainer; | ||||
| 	import com.yahoo.astra.fl.controls.containerClasses.MessageBox; | ||||
| 	import fl.events.ComponentEvent; | ||||
| 	import com.yahoo.astra.fl.controls.containerClasses.TitleBar; | ||||
| 	import flash.display.Stage; | ||||
| 	import fl.core.UIComponent; | ||||
| 	import flash.utils.Dictionary; | ||||
| 	import flash.text.TextFieldAutoSize; | ||||
| 	import flash.filters.DropShadowFilter; | ||||
| 	import flash.events.KeyboardEvent; | ||||
| 	import flash.events.FocusEvent; | ||||
| 	import flash.ui.Keyboard;	 | ||||
| 	import com.yahoo.astra.utils.InstanceFactory; | ||||
| 	import com.yahoo.astra.fl.utils.UIComponentUtil; | ||||
| 	import fl.core.InvalidationType; | ||||
| 	 | ||||
| 	//-------------------------------------- | ||||
| 	//  Styles | ||||
| 	//-------------------------------------- | ||||
| 	 | ||||
|    /**  | ||||
|     *  The skin to be used for the background of the TitleBar. | ||||
|     *   | ||||
|     *  @default Background_skin | ||||
|     */   | ||||
|    [Style(name="skin", type="Class", inherit="no")]   | ||||
|     | ||||
| 	//-------------------------------------- | ||||
| 	//  Class description | ||||
| 	//-------------------------------------- | ||||
|  | ||||
| 	/** | ||||
| 	 * DialogBox extends UIComponent and builds an AlertBox by assembling a TitleBar, | ||||
| 	 * MessageBox and ButtonBar | ||||
| 	 * | ||||
| 	 * @see fl.core.UIComponent | ||||
| 	 * @see com.yahoo.astra.fl.controls.containerClasses.TitleBar | ||||
| 	 * @see com.yahoo.astra.fl.controls.containerClasses.MessageBox | ||||
| 	 * @see com.yahoo.astra.fl.controls.containerClasses.ButtonBar | ||||
| 	 * | ||||
|      * @langversion 3.0 | ||||
|      * @playerversion Flash 9.0.28.0 | ||||
|      * @author Dwight Bridges	 | ||||
| 	 */		 | ||||
| 	public class DialogBox extends UIComponent | ||||
| 	{ | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Constructor | ||||
| 	//-------------------------------------- | ||||
| 	 | ||||
| 		/** | ||||
| 		 * Constructor | ||||
| 		 * | ||||
| 		 * @param container - DisplayObjectContainer to add the alert | ||||
| 		 */ | ||||
| 		public function DialogBox(container:Stage)  | ||||
| 		{ | ||||
| 			_stage = container; | ||||
| 			//set to enforce keyFocusChangeHandler, so that tabbing out does not change focus | ||||
| 			tabChildren = false; | ||||
| 			this.visible = false; | ||||
| 		} | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Constants | ||||
| 	//--------------------------------------		 | ||||
| 	 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		protected const TITLE:String = "title"; | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */		 | ||||
| 		protected const BUTTONS:String = "buttons"; | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Properties | ||||
| 	//--------------------------------------		 | ||||
| 	 | ||||
| 		/** | ||||
| 		 *  @private | ||||
| 		 *  Method for creating the Accessibility class. | ||||
| 		 *  This method is called from UIComponent. | ||||
| 		 */ | ||||
| 		public static var createAccessibilityImplementation:Function; | ||||
| 	 | ||||
| 		/** | ||||
| 		 * @private (protected)  | ||||
| 		 */ | ||||
| 		//instance of the title bar  | ||||
| 		protected var _titleBar:TitleBar; | ||||
| 		 | ||||
| 		public function get titleBar():TitleBar | ||||
| 		{ | ||||
| 			return _titleBar; | ||||
| 		} | ||||
| 		 | ||||
| 		public function setTitleBar(value:TitleBar):void | ||||
| 		{ | ||||
| 			_titleBar = value;	 | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected)  | ||||
| 		 */		 | ||||
| 		//Distance from the top of the component when the user presses his mouse on the  | ||||
| 		//title bar.  Used to calculate the drag. | ||||
| 		protected var _dragOffSetY:Number; | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected)		 | ||||
| 		 */ | ||||
| 		//Distance from the left of the component when the user presses his mouse on the  | ||||
| 		//title bar.  Used to calculate the drag. | ||||
| 		protected var _dragOffSetX:Number; | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Reference to the ButtonBar class instance which manages the buttons | ||||
| 		protected var _buttonBar:ButtonBar; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Manages the display of buttons | ||||
| 		 */ | ||||
| 		public function get buttonBar():ButtonBar | ||||
| 		{ | ||||
| 			return _buttonBar; | ||||
| 		} | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected)  | ||||
| 		 */ | ||||
| 		protected var _minWidth:int;	 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets or sets the minimum width of the dialog box | ||||
| 		 */ | ||||
| 		public function get minWidth():int | ||||
| 		{ | ||||
| 			return _minWidth; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */		 | ||||
| 		public function set minWidth(value:int):void | ||||
| 		{ | ||||
| 			_minWidth = value; | ||||
| 		}		 | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		protected var _maxWidth:int; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets or sets the maximum width of the dialog box | ||||
| 		 */ | ||||
| 		public function get maxWidth():int | ||||
| 		{ | ||||
| 			return _maxWidth; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */ | ||||
| 		public function set maxWidth(value:int):void | ||||
| 		{ | ||||
| 			_maxWidth = value; | ||||
| 			_buttonBar.maxWidth = _maxWidth - (_padding*2); | ||||
| 			_titleBar.maxWidth = _maxWidth; | ||||
| 		}		 | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		protected var _padding:int; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets or sets the padding between components and edges | ||||
| 		 */ | ||||
| 		public function get padding():int | ||||
| 		{ | ||||
| 			return _padding; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */		 | ||||
| 		public function set padding(value:int):void | ||||
| 		{ | ||||
| 			_padding = value; | ||||
| 			_buttonBar.maxWidth = _maxWidth - (_padding*2); | ||||
| 		}		 | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//reference to the stage | ||||
| 		protected var _stage:Stage; | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//background skin  | ||||
| 		protected var _skin:DisplayObject; | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//MessageBox instance used for the text area of the dialog | ||||
| 		protected var _messageBox:MessageBox; | ||||
| 	 | ||||
| 		/** | ||||
| 		 * Text field component that displays message | ||||
| 		 */ | ||||
| 		public function get messageBox():MessageBox | ||||
| 		{ | ||||
| 			return _messageBox; | ||||
| 		} | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//reference to the text field in the message box | ||||
| 		protected var _message:TextField; | ||||
|  | ||||
| 		/** | ||||
| 		 * The text to be rendered in the dialog. | ||||
| 		 */ | ||||
| 		public var messageText:String; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Boolean indicating whether title has been drawn.  Used to determine whether  | ||||
| 		//the elements should be positioned. | ||||
| 		protected var _titleDrawn:Boolean; | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Boolean indicating whether buttons have been drawn.  Used to determine whether  | ||||
| 		//the elements should be positioned</p>		 | ||||
| 		protected var _buttonsDrawn:Boolean; | ||||
| 	 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */		 | ||||
| 		//class to use for an icon image | ||||
| 		protected var _iconClass:DisplayObject; | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//Indicates whether to display an icon graphic | ||||
| 		protected var _hasIcon:Boolean; | ||||
|  | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//collection of icons that can be reused		 		 | ||||
| 		protected var _icons:Dictionary = new Dictionary(); | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 */		 | ||||
| 		private static var defaultStyles:Object =  | ||||
| 		{ | ||||
| 			skin:"Background_skin" | ||||
| 		};  | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Indicates whether the Alert has a drop shadow | ||||
| 		 */ | ||||
| 		public var hasDropShadow:Boolean; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Direction of the drop shadow | ||||
| 		 */ | ||||
| 		public var shadowDirection:String; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets or sets the height of the ButtonBar instance | ||||
| 		 */ | ||||
| 		public function get buttonHeight():int | ||||
| 		{ | ||||
| 			return _buttonBar.height; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */		 | ||||
| 		public function set buttonHeight(value:int):void | ||||
| 		{ | ||||
| 			_buttonBar.height = value; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets or sets the value of the rowSpacing on the buttonBar component | ||||
| 		 */ | ||||
| 		public function get buttonRowSpacing():int | ||||
| 		{ | ||||
| 			return _buttonBar.rowSpacing; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */ | ||||
| 		public function set buttonRowSpacing(value:int):void | ||||
| 		{ | ||||
| 			_buttonBar.rowSpacing = value; | ||||
| 		} | ||||
| 	 | ||||
| 		/** | ||||
| 		 * Gets or sets the value of the spacing on the buttonBar component | ||||
| 		 */ | ||||
| 		public function get buttonSpacing():int | ||||
| 		{ | ||||
| 			return _buttonBar.spacing;	 | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */		  | ||||
| 		public function set buttonSpacing(value:int):void | ||||
| 		{ | ||||
| 			_buttonBar.spacing = value; | ||||
| 		} | ||||
| 				 | ||||
| 	//-------------------------------------- | ||||
| 	//  Public Methods | ||||
| 	//--------------------------------------			 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * returns style definition | ||||
| 		 * | ||||
| 		 * @return defaultStyles object | ||||
| 		 */ | ||||
| 		public static function getStyleDefinition():Object | ||||
| 		{ | ||||
| 			return defaultStyles; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Centers the DialogBox		  | ||||
| 		 */  | ||||
| 		public function positionAlert():void | ||||
| 		{ | ||||
| 			var left:int = _stage.stageWidth/2 - this.width/2; | ||||
| 			var top:int = _stage.stageHeight/3 - this.height/2; | ||||
| 			this.x = left>0?left:0; | ||||
| 			this.y = top>0?top:0; | ||||
| 		}		 | ||||
|  | ||||
| 		/** | ||||
| 		 * Draws a new DialogBox | ||||
| 		 * | ||||
| 		 * @param message - message to be displayed | ||||
| 		 * @param title - title to be displayed | ||||
| 		 * @param buttons - array of buttons to be drawn | ||||
| 		 * @param listeners - array of functions to be attached to the buttons | ||||
| 		 */ | ||||
| 		public function update(message:String, title:String, buttons:Array, listeners:Array, icon:String = null):void | ||||
| 		{						 | ||||
| 			_hasIcon = icon != null; | ||||
| 			_iconClass = null; | ||||
| 			for(var i:String in _icons) | ||||
| 			{ | ||||
| 				_icons[i].visible = false; | ||||
| 				if(_hasIcon && icon == i) | ||||
| 				{ | ||||
| 					_iconClass = _icons[i]; | ||||
| 					_iconClass.visible = true; | ||||
| 				} | ||||
| 			} | ||||
| 			if(_hasIcon && _iconClass == null)  | ||||
| 			{ | ||||
| 				try | ||||
| 				{  | ||||
| 					_iconClass = _icons[icon] = getDisplayObjectInstance(icon); | ||||
| 					this.addChild(_iconClass); | ||||
| 				} | ||||
| 				catch(e:Error) | ||||
| 				{ | ||||
| 					_hasIcon = false; | ||||
| 					delete _icons[icon]; | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			_titleDrawn = _buttonsDrawn = false; | ||||
| 			this.setFocus(); | ||||
| 			if(message != messageText) | ||||
| 			{ | ||||
| 				messageText = message; | ||||
| 			} | ||||
| 			if(title != _titleBar.text) | ||||
| 			{ | ||||
| 				_titleBar.text = title; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				_titleDrawn = true; | ||||
| 			} | ||||
| 			 | ||||
| 			_buttonBar.drawButtons(buttons, listeners);		 | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 * | ||||
| 		 * @langversion 3.0 | ||||
| 		 * @playerversion Flash 9.0.28.0 | ||||
| 		 * override label set text adding setStyle | ||||
| 		 */		 | ||||
| 		override public function setStyle(style:String, value:Object):void  | ||||
| 		{ | ||||
| 			//Use strict equality so we can set a style to null ... so if the instanceStyles[style] == undefined, null is still set. | ||||
| 			//We also need to work around the specific use case of TextFormats | ||||
| 			if (instanceStyles[style] === value && !(value is TextFormat)) { return; } | ||||
| 			if(value is InstanceFactory)  | ||||
| 			{ | ||||
| 				instanceStyles[style] = UIComponentUtil.getDisplayObjectInstance(this, (value as InstanceFactory).createInstance()); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				instanceStyles[style] = value; | ||||
| 			} | ||||
| 			invalidate(InvalidationType.STYLES); | ||||
| 		}		 | ||||
| 		 | ||||
| 		 | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Protected Methods | ||||
| 	//--------------------------------------		 | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */ | ||||
| 		protected override function configUI():void | ||||
| 		{	 | ||||
| 			_titleBar = new TitleBar(); | ||||
| 			_titleBar.buttonMode = true; | ||||
| 			_titleBar.useHandCursor = true;	 | ||||
| 			_titleBar.name = TITLE; | ||||
| 			_titleBar.addEventListener(MouseEvent.MOUSE_DOWN, startDragAlert);			 | ||||
| 			_titleBar.addEventListener(ComponentEvent.RESIZE, resizeHandler); | ||||
| 			this.addChild(_titleBar); | ||||
| 			_messageBox = new MessageBox(); | ||||
| 			_message = _messageBox.textField; | ||||
| 			_message.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler); | ||||
| 			this.addChild(_message); | ||||
| 			_buttonBar = new ButtonBar(); | ||||
| 			_buttonBar.name = BUTTONS;		 | ||||
| 			this.addChild(_buttonBar); | ||||
| 			_buttonBar.addEventListener(ComponentEvent.RESIZE, resizeHandler); | ||||
|  | ||||
| 		} | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */ | ||||
| 		//Fired by the resize event of the buttonBar and titleBar components.  Calls the draw function. | ||||
| 		protected function resizeHandler(evnt:ComponentEvent):void | ||||
| 		{ | ||||
| 			var targetName:String = evnt.target.name; | ||||
| 			if(targetName == TITLE) | ||||
| 			{ | ||||
| 				_titleDrawn = true; | ||||
| 			} | ||||
| 			if(targetName == BUTTONS) _buttonsDrawn = true; | ||||
| 			if(_titleDrawn && _buttonsDrawn) this.drawMessage(); | ||||
| 		} | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */ | ||||
| 		//Compare width of title, buttonBar and _maxWidth.  If buttonBar or titleBar  | ||||
| 		//width is greater than max width, set maxTextWidth and minTextWidth to the  | ||||
| 		//largest value minus total padding.  Otherwise, set maxTextWidth and minTextWidth  | ||||
| 		//to _maxWidth and _minWidth minus total padding, call drawMessage, position and  | ||||
| 		//set sizes of elements		 | ||||
| 		protected function drawMessage():void | ||||
| 		{ | ||||
| 			var minTextWidth:int; | ||||
| 			var maxTextWidth:int; | ||||
| 			var totalPadding:int = _padding*2; | ||||
| 			if(messageText != null) | ||||
| 			{ | ||||
| 				var max:int = Math.max(_minWidth, (_buttonBar.width + totalPadding), _titleBar.width); | ||||
| 				if(max > _minWidth) | ||||
| 				{ | ||||
| 					maxTextWidth = _maxWidth - totalPadding; | ||||
| 					minTextWidth = max - totalPadding; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					maxTextWidth = _maxWidth - totalPadding; | ||||
| 					minTextWidth = _minWidth - totalPadding; | ||||
| 				} | ||||
| 				if(_hasIcon) | ||||
| 				{ | ||||
| 					maxTextWidth -= _iconClass.width + _padding; | ||||
| 					minTextWidth -= _iconClass.width + _padding; | ||||
| 					_messageBox.autoSizeStyle = TextFieldAutoSize.LEFT; | ||||
| 					_iconClass.y = _titleBar.height + _padding; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					_messageBox.autoSizeStyle = TextFieldAutoSize.CENTER; | ||||
| 				} | ||||
| 				 | ||||
| 				_messageBox.drawMessage(maxTextWidth, minTextWidth, messageText); | ||||
| 				_titleBar.y = 0; | ||||
| 				_message.y = _titleBar.height + _padding; | ||||
| 				 | ||||
| 				if(_hasIcon) | ||||
| 				{ | ||||
| 					_buttonBar.y = Math.max(_message.getBounds(this).bottom, _iconClass.getBounds(this).bottom) + _padding;	 | ||||
| 					this.setSize(_message.width+_padding*2+ (_iconClass.width+_padding), _buttonBar.height + _buttonBar.y  + _padding);	 | ||||
| 					_iconClass.x = Math.round(this.width/2) - Math.round((_iconClass.width + _padding + _message.width)/2); | ||||
| 					_message.x = _iconClass.x + _iconClass.width + _padding; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					_buttonBar.y = _message.getBounds(this).bottom + _padding;	 | ||||
| 					this.setSize(_message.width+_padding*2, _buttonBar.height + _buttonBar.y  + _padding);	 | ||||
| 					_message.x = Math.round(this.width/2) - Math.round(_message.width/2); | ||||
| 				} | ||||
| 				 | ||||
| 				 | ||||
| 				_buttonBar.x = Math.round((this.width)/2- (_buttonBar.width)/2); | ||||
| 				_titleBar.drawBackground(this.width); | ||||
| 				this.drawSkin(); | ||||
| 				this.positionAlert(); | ||||
| 				this.visible = true; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */		 | ||||
| 		//Sets dimensions for the background skin of the message box | ||||
| 		protected function drawSkin():void | ||||
| 		{ | ||||
| 			if(_skin != this.getDisplayObjectInstance(getStyleValue("skin"))) | ||||
| 			{ | ||||
| 				if(this.getChildAt(0) == _skin) this.removeChildAt(0); | ||||
| 				_skin = getDisplayObjectInstance(getStyleValue("skin")) | ||||
| 				this.addChildAt(_skin, 0); | ||||
| 			} | ||||
| 			if(_skin != null) | ||||
| 			{ | ||||
| 				_skin.width = this.width; | ||||
| 				_skin.height = this.height; | ||||
| 				if(hasDropShadow) | ||||
| 				{ | ||||
| 					var shadowAngle:int = (shadowDirection == "left")?135:45; | ||||
| 					var filters:Array = []; | ||||
| 					var dropShadow:DropShadowFilter	= new DropShadowFilter(2, shadowAngle, 0x000000, .5, 4, 4, 1, 1, false, false, false); | ||||
| 					filters.push(dropShadow); | ||||
| 					_skin.filters = filters; | ||||
| 				} | ||||
| 			} | ||||
| 		}				 | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */				 | ||||
| 		 //Set x and y offsets based on of the mouse down location | ||||
| 		 //Add mouseMove and mouseUp listeners | ||||
| 		 //Remove the mouseDown listener  | ||||
| 		protected function startDragAlert(evnt:MouseEvent):void | ||||
| 		{ | ||||
| 			_dragOffSetX = Math.round(evnt.localX*evnt.target.scaleX); | ||||
| 			_dragOffSetY = Math.round(evnt.localY*evnt.target.scaleY); | ||||
| 			_stage.addEventListener(MouseEvent.MOUSE_MOVE, dragAlert, false, 0, true); | ||||
| 			_stage.addEventListener(MouseEvent.MOUSE_UP, stopAlertDrag, false, 0, true); | ||||
| 			_titleBar.removeEventListener(MouseEvent.MOUSE_DOWN, startDragAlert); | ||||
| 		} | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */	 | ||||
| 		//Moves the Dialog with the mouse  | ||||
| 		protected function dragAlert(evnt:MouseEvent):void | ||||
| 		{ | ||||
| 			if(evnt.stageX < _stage.stageWidth && evnt.stageY < _stage.stageHeight && evnt.stageX > 0 && evnt.stageY > 0) | ||||
| 			{ | ||||
| 				this.x = evnt.stageX - _dragOffSetX; | ||||
| 				this.y = evnt.stageY - _dragOffSetY; | ||||
| 				evnt.updateAfterEvent();		 | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
|         /** | ||||
|          * @private (protected) | ||||
|          * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */		 | ||||
| 		 //Remove mouseMove and mouseUp listeners | ||||
| 		 //Add the mouseDown listener | ||||
| 		protected function stopAlertDrag(evnt:MouseEvent):void | ||||
| 		{ | ||||
| 			_stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragAlert); | ||||
| 			_stage.removeEventListener(MouseEvent.MOUSE_UP, stopAlertDrag); | ||||
| 			_stage.removeEventListener(Event.MOUSE_LEAVE, stopAlertDrag); | ||||
| 			_titleBar.addEventListener(MouseEvent.MOUSE_DOWN, startDragAlert); | ||||
| 		}	 | ||||
|  | ||||
| 		/* | ||||
| 		 * @private (protected) | ||||
| 		 * | ||||
| 		 * Sets focus on the first button. | ||||
| 		 * | ||||
| 		 * @param event FocusEvent | ||||
| 		 * | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */		 | ||||
| 		protected function keyFocusChangeHandler(event:FocusEvent):void | ||||
| 		{ | ||||
| 			if(event.keyCode == Keyboard.TAB) | ||||
| 			{ | ||||
| 				event.preventDefault(); | ||||
| 				//reset focus to the first button | ||||
| 				_buttonBar.focusIndex = 0; | ||||
| 				//if shift key is pressed, set focus on the last button | ||||
| 				if(event.shiftKey) _buttonBar.setFocusIndex(event.shiftKey); | ||||
| 				_buttonBar.setFocus(); | ||||
| 				_buttonBar.setFocusButton(); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 	     * @private (protected) | ||||
| 	     * @inheritDoc | ||||
| 		 */ | ||||
| 		override protected function initializeAccessibility():void  | ||||
| 		{ | ||||
| 			if (DialogBox.createAccessibilityImplementation != null)  | ||||
| 			{ | ||||
| 				DialogBox.createAccessibilityImplementation(this); | ||||
| 			} | ||||
| 		} | ||||
| 	 | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										168
									
								
								com/yahoo/astra/fl/controls/containerClasses/MessageBox.as
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										168
									
								
								com/yahoo/astra/fl/controls/containerClasses/MessageBox.as
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,168 @@ | ||||
| /* | ||||
| Copyright (c) 2009 Yahoo! Inc.  All rights reserved.   | ||||
| The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license | ||||
| */ | ||||
| package com.yahoo.astra.fl.controls.containerClasses | ||||
| { | ||||
| 	import flash.text.TextField; | ||||
| 	import flash.text.TextFormat; | ||||
| 	import flash.text.TextFieldAutoSize; | ||||
| 	import fl.core.UIComponent; | ||||
|  | ||||
| 	//-------------------------------------- | ||||
| 	//  Styles | ||||
| 	//-------------------------------------- | ||||
| 	 | ||||
|    /** | ||||
|     * The <code>TextFormat</code> object that will be applied to the text. | ||||
|     * | ||||
|     * @default new TextFormat("_sans", 11, 0xffffff) | ||||
|     */ | ||||
|    [Style(name="textFormat", type="TextFormat", inherit="no")] | ||||
|     | ||||
| 	//-------------------------------------- | ||||
| 	//  Class description | ||||
| 	//-------------------------------------- | ||||
|  | ||||
| 	/** | ||||
| 	 * MessageBox extends UIComponent and creates a text field based on minimum and  | ||||
| 	 * maximum widths< | ||||
| 	 * | ||||
| 	 * @see fl.core.UIComponent | ||||
| 	 * | ||||
|      * @langversion 3.0 | ||||
|      * @playerversion Flash 9.0.28.0 | ||||
|      * @author Dwight Bridges	 | ||||
| 	 */	 | ||||
| 	public class MessageBox extends UIComponent | ||||
| 	{ | ||||
|  | ||||
| 	//-------------------------------------- | ||||
| 	//  Constructor | ||||
| 	//-------------------------------------- | ||||
|  | ||||
| 		/** | ||||
| 		 * Constructor | ||||
| 		 */ | ||||
| 		public function MessageBox() | ||||
| 		{ | ||||
| 			_textField = new TextField(); | ||||
| 			_autoSizeStyle = TextFieldAutoSize.CENTER; | ||||
| 			this.setStyle("textFormat", defaultStyles["textFormat"] as TextFormat); | ||||
| 		} | ||||
|  | ||||
| 	//-------------------------------------- | ||||
| 	//  Properties | ||||
| 	//-------------------------------------- | ||||
| 	 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		protected var _textField:TextField;	 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets the value of the text field. (read-only) | ||||
| 		 */ | ||||
| 		public function get textField():TextField | ||||
| 		{ | ||||
| 			return _textField; | ||||
| 		}		 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */		 | ||||
| 		protected var _autoSizeStyle:String; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets or sets autoSizeStyle | ||||
| 		 */ | ||||
| 		public function get autoSizeStyle():String | ||||
| 		{ | ||||
| 			return _autoSizeStyle;	 | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 */	 | ||||
| 		public function set autoSizeStyle(value:String):void {_autoSizeStyle = value;}		 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 */ | ||||
| 		private var defaultStyles:Object =  | ||||
| 		{ | ||||
| 			textFormat:new TextFormat("_sans", 11, 0xffffff) | ||||
| 		} | ||||
| 		  | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Public Methods | ||||
| 	//--------------------------------------		 | ||||
|  | ||||
| 		/** | ||||
| 		 * Displays the message text and updates the height of the MessageBox | ||||
| 		 * | ||||
| 		 * @param maxTextWidth - maximum width allowed for textfield		  | ||||
| 		 * @param minTextWidth - minimum width allowed for textfield | ||||
| 		 * @param messageText - string to display in the text field | ||||
| 		 */  | ||||
| 		public function drawMessage(maxTextWidth:int, minTextWidth:int, messageText:String):void | ||||
| 		{ | ||||
| 			var textFieldWidth:int = getTextFieldWidth(messageText, maxTextWidth, minTextWidth); | ||||
| 			_textField.multiline = false; | ||||
| 			_textField.wordWrap = true; | ||||
| 			_textField.autoSize = _autoSizeStyle; | ||||
| 			_textField.width = textFieldWidth; | ||||
| 			_textField.height = 5; | ||||
| 			var tF:TextFormat = getStyle("textFormat") as TextFormat; | ||||
| 			tF.align = _autoSizeStyle; | ||||
| 			_textField.defaultTextFormat = tF; | ||||
| 			_textField.text = messageText; | ||||
| 			this.width = _textField.width; | ||||
| 		} | ||||
| 	 | ||||
| 	//-------------------------------------- | ||||
| 	//  Protected Methods | ||||
| 	//-------------------------------------- | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 * Gets the width of the text field. | ||||
| 		 * | ||||
| 		 * @param message - text to use | ||||
| 		 * @param maxTextWidth - maximum width allowed for textfield		  | ||||
| 		 * @paramminTextWidth - minimum width allowed for textfield		  | ||||
| 		 * | ||||
| 		 * @return int | ||||
| 		 */ | ||||
| 		protected function getTextFieldWidth(message:String, maxTextWidth:int, minTextWidth:int):int | ||||
| 		{ | ||||
| 			var textFieldWidth:int; | ||||
| 			var tempText:TextField = new TextField(); | ||||
| 			var tF:TextFormat = new TextFormat("_sans", 11); | ||||
| 			tF.align = _autoSizeStyle;	 | ||||
| 			tempText.defaultTextFormat = this.getStyle("textFormat") as TextFormat;			 | ||||
| 			tempText.width = 10; | ||||
| 			tempText.height = 5; | ||||
| 			tempText.wordWrap = false; | ||||
| 			tempText.multiline = false; | ||||
| 			tempText.autoSize = TextFieldAutoSize.LEFT; | ||||
| 			tempText.text = message; | ||||
| 			var tempTextWidth:int = Math.round(tempText.width); | ||||
| 			if(tempTextWidth > maxTextWidth) | ||||
| 			{ | ||||
| 				textFieldWidth = maxTextWidth;				 | ||||
| 			} | ||||
| 			else if(tempTextWidth > minTextWidth) | ||||
| 			{ | ||||
| 				textFieldWidth = tempTextWidth; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				textFieldWidth = minTextWidth; | ||||
| 			}		 | ||||
| 			if(_autoSizeStyle == TextFieldAutoSize.LEFT) textFieldWidth += 1; | ||||
| 			return textFieldWidth;			 | ||||
| 		}		 | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										300
									
								
								com/yahoo/astra/fl/controls/containerClasses/TitleBar.as
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										300
									
								
								com/yahoo/astra/fl/controls/containerClasses/TitleBar.as
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,300 @@ | ||||
| /* | ||||
| Copyright (c) 2009 Yahoo! Inc.  All rights reserved.   | ||||
| The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license | ||||
| */ | ||||
| package com.yahoo.astra.fl.controls.containerClasses | ||||
| { | ||||
| 	import fl.controls.Label; | ||||
| 	import flash.text.TextFormatAlign; | ||||
| 	import flash.text.TextFieldAutoSize; | ||||
| 	import flash.text.TextFormat;	 | ||||
| 	import flash.display.DisplayObject; | ||||
| 	import fl.events.ComponentEvent; | ||||
| 	import fl.core.InvalidationType; | ||||
| 	import fl.core.UIComponent; | ||||
| 	import com.yahoo.astra.utils.InstanceFactory; | ||||
| 	import com.yahoo.astra.fl.utils.UIComponentUtil; | ||||
| 	 | ||||
| 	//-------------------------------------- | ||||
| 	//  Styles | ||||
| 	//-------------------------------------- | ||||
| 	 | ||||
|    /**  | ||||
|     *  The skin to be used for the background of the TitleBar. | ||||
|     *   | ||||
|     *  @default Title_skin  | ||||
|     */   | ||||
|    [Style(name="backgroundSkin", type="Class", inherit="no")]   | ||||
|     | ||||
|    /** | ||||
|     * The <code>TextFormat</code> object that will be applied to the title  | ||||
|     * text. | ||||
|     * | ||||
|     * @default TextFormat("_sans", 11, 0xffffff, true, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0) | ||||
|     */ | ||||
|    [Style(name="textFormat", type="TextFormat", inherit="no")] | ||||
|     | ||||
| 	//-------------------------------------- | ||||
| 	//  Class description | ||||
| 	//-------------------------------------- | ||||
|  | ||||
| 	/** | ||||
| 	 * TitleBar extends Label, adding a background.  It is used by DialogBox. | ||||
| 	 * | ||||
|      * @see fl.controls.Label | ||||
|      * @see com.yahoo.astra.fl.controls.containerClasses.DialogBox | ||||
| 	 * | ||||
|      * @langversion 3.0 | ||||
|      * @playerversion Flash 9.0.28.0 | ||||
|      * @author Dwight Bridges	 | ||||
| 	 */		 | ||||
| 	public class TitleBar extends Label | ||||
| 	{ | ||||
|  | ||||
| 	//-------------------------------------- | ||||
| 	//  Constructor | ||||
| 	//--------------------------------------	 | ||||
| 	 | ||||
| 		/** | ||||
| 		* Constructor | ||||
| 		*/ | ||||
| 		public function TitleBar() | ||||
| 		{ | ||||
| 			super(); | ||||
| 			this.setTitleBarStyles(); | ||||
| 		}		 | ||||
|  | ||||
| 	//-------------------------------------- | ||||
| 	//  Properties | ||||
| 	//--------------------------------------		 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 */ | ||||
| 		//background for the title bar | ||||
| 		protected var background:DisplayObject; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Maximum width of the TitleBar instance | ||||
| 		 */ | ||||
| 		public var maxWidth:int;		 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 * Default style values for the titlebar | ||||
| 		 */ | ||||
| 		private static var defaultStyles:Object =  | ||||
| 		{ | ||||
| 			backgroundSkin:"Title_skin", | ||||
| 			textFormat:new TextFormat("_sans", 11, 0xffffff, true, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0) | ||||
| 		}; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 * Styles for titlebar | ||||
| 		 */ | ||||
| 		private const TITLEBAR_STYLES:Object = | ||||
| 		{ | ||||
| 			backgroundSkin:"backgroundSkin", | ||||
| 			textFormat:"textFormat" | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 */ | ||||
| 		private var _titleText:String = ""; | ||||
| 			 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 * | ||||
| 		 * @langversion 3.0 | ||||
| 		 * @playerversion Flash 9.0.28.0 | ||||
| 		 * override label set text adding setStyle | ||||
| 		 */		 | ||||
| 		override public function set text(value:String):void | ||||
| 		{ | ||||
| 			if (value == this.text) return; | ||||
| 			// Clear the HTML value, and redraw. | ||||
| 			_html = false; | ||||
| 			_titleText = value; | ||||
| 				 | ||||
| 			textField.text = _titleText; | ||||
| 		 | ||||
| 			// Value in the PI is the default. | ||||
| 			if (componentInspectorSetting && value == defaultLabel)  | ||||
| 			{ | ||||
| 				return; | ||||
| 			} | ||||
| 			 | ||||
| 			if (textField.autoSize != TextFieldAutoSize.NONE)  | ||||
| 			{  | ||||
| 				invalidate(InvalidationType.SIZE); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (setter) | ||||
| 		 * | ||||
| 		 * @langversion 3.0 | ||||
| 		 * @playerversion Flash 9.0.28.0 | ||||
| 		 */	 | ||||
| 		override public function get height():Number | ||||
| 		{ | ||||
| 			var ht:Number = actualHeight; | ||||
| 			if(!isNaN(ht)) ht = _height; | ||||
| 			if(!isNaN(ht)) ht = this.textField.height; | ||||
| 			return _height; | ||||
| 		}		 | ||||
| 		 | ||||
| 	//-------------------------------------- | ||||
| 	//  Public Methods | ||||
| 	//--------------------------------------				 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @return defaultStyles | ||||
| 		 */ | ||||
| 		public static function getStyleDefinition():Object | ||||
| 		{ | ||||
| 			return mergeStyles(defaultStyles); | ||||
| 		}	 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Resizes the background skin | ||||
| 		 * | ||||
| 		 * @param wid - width to set the background | ||||
| 		 * | ||||
| 		 * @langversion 3.0 | ||||
| 		 * @playerversion Flash 9.0.28.0 | ||||
| 		 */	 | ||||
| 		public function drawBackground(wid:Number):void | ||||
| 		{ | ||||
| 			if(this.background != getDisplayObjectInstance(getStyleValue("backgroundSkin"))) | ||||
| 			{ | ||||
| 				if(this.getChildAt(0) == this.background) this.removeChild(this.background);				  | ||||
| 				this.background = getDisplayObjectInstance(getStyleValue("backgroundSkin")); | ||||
| 				this.addChildAt(background, 0); | ||||
| 			} | ||||
| 			if(this.background != null) | ||||
| 			{ | ||||
| 				this.background.width = wid;	 | ||||
| 				this.background.height = _height; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @public | ||||
|          * | ||||
| 		 * @copy fl.core.UIComponent#setStyle() | ||||
|          *           | ||||
|          * @langversion 3.0 | ||||
|          * @playerversion Flash 9.0.28.0 | ||||
| 		 */			 | ||||
| 		override public function setStyle(style:String, value:Object):void { | ||||
| 			//Use strict equality so we can set a style to null ... so if the instanceStyles[style] == undefined, null is still set. | ||||
| 			//We also need to work around the specific use case of TextFormats | ||||
| 			if (instanceStyles[style] === value && !(value is TextFormat)) { return; } | ||||
| 			if(value is InstanceFactory)  | ||||
| 			{ | ||||
| 				instanceStyles[style] = UIComponentUtil.getDisplayObjectInstance(this, (value as InstanceFactory).createInstance()); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				instanceStyles[style] = value; | ||||
| 			} | ||||
| 			invalidate(InvalidationType.STYLES); | ||||
| 		} | ||||
| 		 | ||||
|  | ||||
| 	//-------------------------------------- | ||||
| 	//  Protected methods | ||||
| 	//--------------------------------------				 | ||||
| 				 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 * | ||||
| 		 * @langversion 3.0 | ||||
| 		 * @playerversion Flash 9.0.28.0 | ||||
| 		 */			  | ||||
| 		override protected function configUI():void | ||||
| 		{ | ||||
| 			super.configUI(); | ||||
| 			this.textField.mouseEnabled = false; | ||||
| 			this.wordWrap = false; | ||||
| 			this.textField.autoSize = TextFieldAutoSize.LEFT; | ||||
| 		}	 | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private (protected) | ||||
| 		 * | ||||
| 		 * @langversion 3.0 | ||||
| 		 * @playerversion Flash 9.0.28.0 | ||||
| 		 */ | ||||
| 		 //Truncate the text field and call drawLayout if the text width is greater than   | ||||
| 		 //the maxWidth.  If not, dispatch the resize event | ||||
| 		override protected function drawLayout():void  | ||||
| 		{ | ||||
| 			var resized:Boolean = false; | ||||
| 			 | ||||
| 			textField.width = width; | ||||
| 			textField.height = height;			 | ||||
| 			 | ||||
| 			if (textField.autoSize != TextFieldAutoSize.NONE)  | ||||
| 			{ | ||||
| 				 | ||||
| 				var txtW:Number = textField.width; | ||||
| 				var txtH:Number = textField.height; | ||||
| 				 | ||||
| 				resized = (_width != txtW || _height != txtH);				 | ||||
| 				// set the properties directly, so we don't trigger a callLater: | ||||
| 				_width = txtW; | ||||
| 				_height = txtH; | ||||
| 				 | ||||
| 				switch (textField.autoSize)  | ||||
| 				{ | ||||
| 					case TextFieldAutoSize.CENTER: | ||||
| 						textField.x = (actualWidth/2)-(textField.width/2); | ||||
| 						break; | ||||
| 					case TextFieldAutoSize.LEFT: | ||||
| 						textField.x = 0; | ||||
| 						break; | ||||
| 					case TextFieldAutoSize.RIGHT: | ||||
| 						textField.x = -(textField.width - actualWidth); | ||||
| 						break; | ||||
| 				} | ||||
| 			}  | ||||
| 			else  | ||||
| 			{ | ||||
| 				textField.width = actualWidth; | ||||
| 				textField.height = actualHeight; | ||||
| 				textField.x = 0;	 | ||||
| 			} | ||||
|  | ||||
| 			if(!isNaN(_width) && !isNaN(maxWidth) && maxWidth > 0 && _width > 0 &&  _width > maxWidth) | ||||
| 			{ | ||||
| 				var truncatedText:String;					 | ||||
| 				var tempText:String = _titleText; | ||||
| 				truncatedText = (tempText.lastIndexOf(" ") > 0)?tempText.slice(0, tempText.lastIndexOf(" ")) + "...":tempText.slice(0, this.textField.getCharIndexAtPoint(maxWidth, Math.round(_height/2)) - 3) + "..."; | ||||
| 				textField.text = truncatedText; | ||||
| 				drawLayout(); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, true)); | ||||
| 			}				 | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * @private | ||||
| 		 * | ||||
| 		 * Set the styles for title bar | ||||
| 		 */ | ||||
| 		private function setTitleBarStyles():void | ||||
| 		{ | ||||
| 			for(var i:String in TITLEBAR_STYLES) | ||||
| 			{ | ||||
| 				this.setStyle(TITLEBAR_STYLES[i], defaultStyles[i]); | ||||
| 			} | ||||
| 		}		 | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user