summaryrefslogtreecommitdiff
path: root/bPod/com/oop/UIButton.as
diff options
context:
space:
mode:
authorJules Laplace <carbon@melanarchy.org>2013-08-02 17:14:26 -0500
committerJules Laplace <carbon@melanarchy.org>2013-08-02 17:14:26 -0500
commit79670053c7247d3a49b607960efd284e93f057e5 (patch)
tree9617f6eefa38b2686ae409bf75cc27a340444eda /bPod/com/oop/UIButton.as
parentc53827d5d044ae5ca7ebb27acb404b7a8988918e (diff)
install.pl
Diffstat (limited to 'bPod/com/oop/UIButton.as')
-rw-r--r--bPod/com/oop/UIButton.as171
1 files changed, 171 insertions, 0 deletions
diff --git a/bPod/com/oop/UIButton.as b/bPod/com/oop/UIButton.as
new file mode 100644
index 0000000..035c16c
--- /dev/null
+++ b/bPod/com/oop/UIButton.as
@@ -0,0 +1,171 @@
+
+
+import com.oop.SelectionSystem;
+
+class com.oop.UIButton extends MovieClip
+{
+
+//--------------------------------------------------------------------------------------------
+
+ // Stores a reference to a SelectionSystem instance
+ private var selectionSystem:Object;
+
+ // Numeric id passed in by SelectionSystem when attached
+ private var id:Number;
+
+
+
+
+ // Keeps track of the selection status of this clip
+ private var selected:Boolean;
+
+ // Holds any custom visual information (such as title)
+ private var itemData:Object;
+
+ // stores the history of this item
+ private var visited:Boolean;
+
+
+
+
+//--------------------------------------------------------------------------------------------
+// constructor
+//--------------------------------------------------------------------------------------------
+
+ public function UIButton()
+ {
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ /*
+ Set up our reference, ID, and item data
+ then take care of the clip's ui
+ */
+ public function init(_selectionSystem:SelectionSystem, _id:Number, _itemData:Object ):Void
+ {
+ selectionSystem = _selectionSystem;
+ itemData = _itemData;
+ id = _id;
+ _focusrect = false;
+ initMouseEvents();
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ /*
+ Select this clip. It will stay visually selected
+ because the mouse is rolled over it
+ */
+ private function setSelected():Void
+ {
+ selected = visited = true;
+ killMouseEvents();
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ /*
+ Unselect this clip
+ */
+ private function setUnselected():Void
+ {
+ selected = false;
+ initMouseEvents();
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ private function setTitle(_val:Object):Void
+ {
+ // override
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ private function setPosition():Void
+ {
+ //override
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ /*
+ Tell selectionSystem about the click and pass this clips ID with it
+ */
+ private function handleRelease():Void
+ {
+ selectionSystem.setSelection(id);
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ private function handlePress():Void
+ {
+ //override
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ private function handleRollOver():Void
+ {
+ //override
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ private function handleRollOut():Void
+ {
+ //override
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ /*
+ Capture all of our mouse events and pass them
+ to the internal hander methods
+ */
+ private function initMouseEvents() : Void
+ {
+ useHandCursor = false;
+ onRollOver = handleRollOver;
+ onRollOut = handleRollOut;
+ onReleaseOutside = handleRollOut;
+ onPress = handlePress;
+ onRelease = handleRelease;
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ /*
+ Remove all mouse events while the clip is selected
+ */
+ private function killMouseEvents():Void
+ {
+ useHandCursor = false;
+ delete onRollOver;
+ delete onRollOut;
+ delete onReleaseOutside;
+ delete this.onPress;
+ delete this.onRelease;
+ }
+
+//--------------------------------------------------------------------------------------------
+// Getter/Setters
+//--------------------------------------------------------------------------------------------
+
+ public function getId():Number
+ {
+ return id;
+ }
+
+//--------------------------------------------------------------------------------------------
+
+ public function setId(_val:Number):Void
+ {
+ id = _val;
+ }
+
+//--------------------------------------------------------------------------------------------
+
+}