Created
July 8, 2009 18:05
-
-
Save camwest/143021 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.yardstick.shared.ui.controls | |
| { | |
| import com.yardstick.shared.events.ActionPanelEvent; | |
| import flash.events.Event; | |
| import flash.events.MouseEvent; | |
| import spark.components.SkinnableContainer; | |
| import spark.components.supportClasses.ButtonBase; | |
| import spark.primitives.supportClasses.TextGraphicElement; | |
| [Event(name="action", type="com.yardstick.shared.events.ActionPanelEvent")] | |
| public class ActionPanel extends SkinnableContainer | |
| { | |
| //-------------------------------------- | |
| // Public Getters & Settings | |
| //-------------------------------------- | |
| // ~~~~~~~~~~~~~~ label ~~~~~~~~~~~~~~~~~~ | |
| private var _actionLabel:String; | |
| [Inspectable(category="Common", defaultValue="Action!", type="String")] | |
| [Bindable(Event="actionLabelChanged")] public function get actionLabel():String | |
| { | |
| return _actionLabel; | |
| } | |
| public function set actionLabel(value:String):void | |
| { | |
| _actionLabel = value; | |
| dispatchEvent( new Event("actionLabelChanged") ); | |
| if (actionButton) | |
| actionButton.label = value; | |
| } | |
| // ~~~~~~~~~~~~~~ title ~~~~~~~~~~~~~~~~~~ | |
| private var _title:String = ""; | |
| [Bindable(Event="titleChanged")] public function get title():String | |
| { | |
| return _title; | |
| } | |
| public function set title(value:String):void | |
| { | |
| _title = value; | |
| dispatchEvent( new Event("titleChanged") ); | |
| if (titleField) | |
| titleField.text = title; | |
| } | |
| //-------------------------------------- | |
| // Skin Parts | |
| //-------------------------------------- | |
| [SkinPart(required="true")] | |
| public var actionButton:ButtonBase; | |
| [SkinPart(required="true")] | |
| public var titleField:TextGraphicElement; | |
| //-------------------------------------- | |
| // Constructor | |
| //-------------------------------------- | |
| public function ActionPanel() | |
| { | |
| super(); | |
| } | |
| //-------------------------------------- | |
| // Protected Methods | |
| //-------------------------------------- | |
| //-------------------------------------- | |
| // Event Handlers | |
| //-------------------------------------- | |
| private function actionEventHandler(e:MouseEvent):void | |
| { | |
| dispatchEvent( new ActionPanelEvent( ActionPanelEvent.ACTION ) ); | |
| } | |
| //-------------------------------------- | |
| // Overridden Properties | |
| //-------------------------------------- | |
| override protected function partAdded(partName:String, instance:Object):void | |
| { | |
| super.partAdded(partName, instance); | |
| if (instance == actionButton) { | |
| actionButton.label = actionLabel; | |
| actionButton.addEventListener(MouseEvent.CLICK, actionEventHandler, false, 0, true); | |
| } | |
| if (instance == titleField) { | |
| titleField.text = title; | |
| } | |
| } | |
| override protected function partRemoved(partName:String, instance:Object):void { | |
| super.partRemoved(partName, instance); | |
| if (instance == actionButton) { | |
| actionButton.removeEventListener(MouseEvent.CLICK, actionEventHandler); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment