From 79670053c7247d3a49b607960efd284e93f057e5 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:14:26 -0500 Subject: install.pl --- bPod/com/oop/GridSelectionSystem.as | 49 +++++++++ bPod/com/oop/ScrollingMenuFrame.as | 148 +++++++++++++++++++++++++++ bPod/com/oop/SelectionSwitcher.as | 194 ++++++++++++++++++++++++++++++++++++ bPod/com/oop/SelectionSystem.as | 89 +++++++++++++++++ bPod/com/oop/UIButton.as | 171 +++++++++++++++++++++++++++++++ 5 files changed, 651 insertions(+) create mode 100644 bPod/com/oop/GridSelectionSystem.as create mode 100644 bPod/com/oop/ScrollingMenuFrame.as create mode 100644 bPod/com/oop/SelectionSwitcher.as create mode 100644 bPod/com/oop/SelectionSystem.as create mode 100644 bPod/com/oop/UIButton.as (limited to 'bPod/com/oop') diff --git a/bPod/com/oop/GridSelectionSystem.as b/bPod/com/oop/GridSelectionSystem.as new file mode 100644 index 0000000..c9694ca --- /dev/null +++ b/bPod/com/oop/GridSelectionSystem.as @@ -0,0 +1,49 @@ +import com.oop.SelectionSystem; + +class com.oop.GridSelectionSystem extends SelectionSystem +{ + private var itemsPerRow:Number = 3; + private var currentRow:Number = 0; + private var currentColumn:Number = 0; + + //space between rows and columns + private var horizSpace:Number = -6; //60; + private var vertSpace:Number = 0; //50; + + public function GridSelectionSystem() {} + + private function attachButtonItems():Void { + //get placement object according to counts + for (var i:Number = 0; i < systemData.length; i++) { + updateGrid(i); + var item:MovieClip = this.attachMovie(exportName, "Item_" + i, i ); + item.init(this, i, systemData[i], getItemPositionObj()); + listItems.push(item); + } + } + + + + private function updateGrid(_index:Number) { + if(!(_index % itemsPerRow)) { currentColumn = 0; currentRow++; } + else { currentColumn++; } + } + + + private function getItemPositionObj():Object { + var obj:Object = new Object(); + obj.horizSpace = horizSpace; + obj.vertSpace = vertSpace; + obj.grid_x = currentColumn; + obj.grid_y = currentRow; + return obj; + } + + + + private function selectedData():MovieClip { + return systemData[ getCurrentSelection() ]; + } + + +} \ No newline at end of file diff --git a/bPod/com/oop/ScrollingMenuFrame.as b/bPod/com/oop/ScrollingMenuFrame.as new file mode 100644 index 0000000..5c91751 --- /dev/null +++ b/bPod/com/oop/ScrollingMenuFrame.as @@ -0,0 +1,148 @@ + +class com.oop.ScrollingMenuFrame extends MovieClip +{ + private var hotSpot_mc:MovieClip; // used to detect mouse events + private var holder_mc:MovieClip; // holder for the flat-list SelectionSystem + private var hotSpotMask:MovieClip; // bluh .. also used i guess + + private var initY:Number; + private var initX:Number; + + private var initHolderX:Number; + private var initHolderY:Number; + + var intRate:Number = 10; // scroller speed + + + public function ScrollingMenuFrame() { + doInit(); + } + + +/* public function doLoad(_dataArray:Array):Void { + holder_mc.attachMovie("KeywordSelectionSystem", "keywordTiles", 1000); + holder_mc["keywordTiles"].doInit(_dataArray, "KeywordButton"); + } +*/ + public function enableMenu():Void { + initMenuScroll(); + initMouseWatch(); + setHotSpot(true); + } + + + public function disableMenu():Void { + killMouseWatch(); + killMenuScroll(); + setHotSpot(false); + } + + + private function doInit():Void { + + initY = _x; + initX = _y; + + initHolderX = holder_mc._x; + initHolderY = holder_mc._y; + + initMenuScroll(); + + holder_mc.onMouseDown = function() { + if (this.hitTest(_root._xmouse, _root._ymouse, true)) { +// _parent.disableMenu(); + } + } + } + + + private function setHotSpot(_isMenuEnabled:Boolean):Void { + if (_isMenuEnabled) { + hotSpot_mc.onRollOver = undefined; + } else { + hotSpot_mc.onRollOver = function() { + this._parent.enableMenu(); + } + } + } + + + + private function initMouseWatch():Void { + this.onMouseMove = function() { + if (!this.hitTest(_root._xmouse, _root._ymouse, true)) { + disableMenu(); + } + } + } + + + private function killMouseWatch():Void { + this.onMouseMove = undefined; + } + + + private function initMenuScroll():Void { + this.onEnterFrame = function() { + if ((holder_mc._height >= hotSpotMask._height) || (holder_mc._width >= hotSpotMask._width)) { + doMenuScroll(); + } + } + } + + + private function killMenuScroll():Void { + this.onEnterFrame = undefined; + } + + + private function doMenuScroll():Void { + var intTop:Number = initHolderY; + var intLeft:Number = initHolderX; + var intBottom:Number = intTop + hotSpotMask._height; + var intRight:Number = intLeft + hotSpotMask._width; + + + var intZero:Number = (intBottom + intTop) / 2; + var intZeroW:Number = (intRight + intLeft) / 2; + + var intMousePos:Number = _ymouse - intZero; + var intMousePosW:Number = _xmouse - intZeroW; + + var intMaxUp:Number = intTop - intZero; + var intMaxLeft:Number = intLeft - intZeroW; + var intMaxDown:Number = intBottom - intZero; + var intMaxRight:Number = intRight - intZeroW; + + var _isHit:Boolean = this.hitTest(_root._xmouse, _root._ymouse, true); + + if (_isHit) { + + if (holder_mc._height > hotSpotMask._height ) { + + // top & bottom bounds check + + if (intMousePos > 0) { // below intZero? scroll up + holder_mc._y = Math.max(holder_mc._y - intRate * Math.pow((intMousePos/intMaxDown),2), intBottom - holder_mc._height) ; + } + else if (intMousePos < 0) { // above intZero? scroll down + holder_mc._y = Math.min(holder_mc._y + intRate * Math.pow((intMousePos/intMaxUp),2), intTop ); + } + + + // left & right bounds check + +/* if (intMousePosW > 0) { // right of intZero? scroll left + holder_mc._x = Math.max(holder_mc._x - intRate * Math.pow((intMousePosW/intMaxRight),2), intRight - holder_mc._width); + } + else if (intMousePosW < 0) { // left of intZero? scroll right + holder_mc._x = Math.min(holder_mc._x + intRate * Math.pow((intMousePosW/intMaxLeft),2), intLeft); + } +*/ + + } + + } + + } +} diff --git a/bPod/com/oop/SelectionSwitcher.as b/bPod/com/oop/SelectionSwitcher.as new file mode 100644 index 0000000..f5685ea --- /dev/null +++ b/bPod/com/oop/SelectionSwitcher.as @@ -0,0 +1,194 @@ +import mx.utils.Delegate; +import com.services.BuckyServices; +import com.events.EventBroadcaster; +import mx.transitions.easing.Regular; +import mx.transitions.Tween; + +class com.oop.SelectionSwitcher extends MovieClip +{ + private static var slideAround:Boolean = true; // turn off while debugging only + + private var selectionsMC:MovieClip; // all scrolling selection systems + private var initX:Number; // where they start + private var initY:Number; + + private var bb:MovieClip; // back button + + private var bbX:Number; // starting positions of nav buttons; + private var thX:Number; + private var kwX:Number; + + private var initAlpha:Number = 70; + + private var openKeywordsBtn:MovieClip; // open keywords button + private var openThreadBtn:MovieClip; // open threads button + + private var currentView:String; // might as well be a string + private var agreedAlpha:Number = 75; + private var slideAmountX:Number = 210; + private var slideAmountY:Number = 210; + private var slideSpeed:Number = .4 + private var activeThread:String; // to open a new browser window instead of + // switching to keyword/thread/file view. + + public function SelectionSwitcher() { + establishStartingPoints(); + EventBroadcaster.getInstance().addEventListener("switchToKeywordsView", this); + EventBroadcaster.getInstance().addEventListener("switchToThreadsView", this); + EventBroadcaster.getInstance().addEventListener("switchToFilesView", this); + + EventBroadcaster.getInstance().addEventListener("switchToFeedThreadsView", this); + + + bb.onRelease = Delegate.create (this, handleBackButton); + openKeywordsBtn.onRelease = Delegate.create (this, handleOpenKeywordsBtn); + openThreadBtn.onRelease = Delegate.create (this, handleOpenThreadBtn); + } + + private function handleBackButton():Void { + switch (currentView) { + case "threads" : switchToKeywordsView(); break; + case "files" : switchToThreadsView(); break; + case "feeds" : switchToFeedsView(); break; + default : break; + } + } + + private function establishStartingPoints():Void { + initX = selectionsMC._x; + initY = selectionsMC._y; + bbX= bb._x; + thX= openThreadBtn._x; + kwX= openKeywordsBtn._x; + currentView = "keywords"; + hideBackButton(); + hideOpenThreadBtn(); + hideOpenKeywordsBtn(); + + bb._alpha = openKeywordsBtn._alpha = openThreadBtn._alpha = initAlpha; + } + + private function swapPlaces(_inA:MovieClip, _inB:MovieClip):Void { + + var oldX:Number = _inA._x; + var oldY:Number = _inA._y; + + _inA._x = _inB._x; + _inA._y = _inB._y; + + _inB._x = oldX; + _inB._y = oldY; + } + + private function handleOpenKeywordsBtn():Void { + switchToKeywordsView(); + } + + public function handleOpenThreadBtn():Void { + getURL ( BuckyServices.activeThreadPath , "_blank"); + } + + public function switchToKeywordsView(_evt:Object):Void { + removeAnyThumbnails(); + hideBackButton(); + hideOpenKeywordsBtn(); + hideOpenThreadBtn(); + _root.thumbnail.removeMovieClip(); + + // swapPlaces ( BuckyServices.threadsMC , BuckyServices.feedThreadsMC ); + + if (slideAround) { + var sTween = new Tween(selectionsMC, "_x", Regular.easeOut, selectionsMC._x, initX, slideSpeed, true); + } + currentView = "keywords"; + } + + + public function switchToFeedsView(_evt:Object):Void { + removeAnyThumbnails(); + hideBackButton(); + hideOpenKeywordsBtn(); + hideOpenThreadBtn(); + _root.thumbnail.removeMovieClip(); + +// swapPlaces ( BuckyServices.threadsMC , BuckyServices.feedThreadsMC ); + + if (slideAround) { + var xTween = new Tween(selectionsMC, "_x", Regular.easeOut, selectionsMC._x, initX, slideSpeed, true); + var yTween = new Tween(selectionsMC, "_y", Regular.easeOut, selectionsMC._y, initY, slideSpeed, true); + } + currentView = "feeds"; + } + + + + + public function switchToThreadsView(_evt:Object):Void { + removeAnyThumbnails(); + hideOpenKeywordsBtn(); + hideOpenThreadBtn(); + _root.thumbnail.removeMovieClip(); + + if (slideAround) { + var sTween = new Tween(selectionsMC, "_x", Regular.easeOut, selectionsMC._x, -slideAmountX, slideSpeed, true); + sTween.onMotionFinished = Delegate.create (this, showBackButton); + } + currentView = "threads"; + } + + + + public function switchToFeedThreadsView(_evt:Object):Void { + removeAnyThumbnails(); + hideOpenKeywordsBtn(); + hideOpenThreadBtn(); + _root.thumbnail.removeMovieClip(); + + if (slideAround) { + var sTween = new Tween(selectionsMC, "_y", Regular.easeOut, selectionsMC._y, -slideAmountY, slideSpeed, true); + var sTween = new Tween(selectionsMC, "_x", Regular.easeOut, selectionsMC._x, -slideAmountX, slideSpeed, true); + sTween.onMotionFinished = Delegate.create (this, showBackButton); + } + currentView = "feeds"; + } + + + + + + + + public function switchToFilesView(_evt:Object):Void { +// removeAnyThumbnails(); + showOpenKeywordsBtn(); + showOpenThreadBtn(); + + if (slideAround) { + var sTween = new Tween(selectionsMC, "_x", Regular.easeOut, selectionsMC._x, -slideAmountX*2, slideSpeed, true); + sTween.onMotionFinished = Delegate.create (this, showBackButton); + } + currentView = "files"; + } + + + + + + + + public function removeAnyThumbnails():Void { + _root.imagesHolder.thumbnail.unloadMovie(); + } + + + private function showBackButton():Void { bb._x = bbX; } + private function showOpenKeywordsBtn():Void { openKeywordsBtn._x = kwX; } + private function showOpenThreadBtn():Void { openThreadBtn._x = thX; } + + private function hideBackButton():Void { bb._x = -5000; } + private function hideOpenKeywordsBtn():Void { openKeywordsBtn._x = -5000; } + private function hideOpenThreadBtn():Void { openThreadBtn._x = -5000; } + + + +} diff --git a/bPod/com/oop/SelectionSystem.as b/bPod/com/oop/SelectionSystem.as new file mode 100644 index 0000000..2c89bf0 --- /dev/null +++ b/bPod/com/oop/SelectionSystem.as @@ -0,0 +1,89 @@ +/* + Manages a set of UI Buttons and controls selection state +*/ + +class com.oop.SelectionSystem extends MovieClip +{ + +//---------------------------------------------------------------------------------- + + + + // Data array passed in at instantiation + private var systemData:Array; + + // Linkage name of button clip + private var exportName:String; + + // Store our current state as a number + private var currentSelection:Number; + + // Store references to our items + private var listItems:Array; + + + + + +//---------------------------------------------------------------------------------- + + public function SelectionSystem() + { + + } + +//---------------------------------------------------------------------------------- + + public function doInit(_systemData:Array, _exportName:String):Void + { + systemData = _systemData; + exportName = _exportName; + listItems = new Array(); + attachButtonItems(); + + } + + + + public function setSelection(_id:Number):Void + { + if(currentSelection!=_id) + { + listItems[currentSelection].setUnselected(); + currentSelection = _id; + listItems[currentSelection].setSelected(); + doAction(); + } + } + + private function attachButtonItems():Void { + //override + } + + + private function doAction():Void + { + //override + } + + + // Getter/setters + + public function getSystemData():Array + { + return systemData; + } + + public function getCurrentSelection():Number + { + return currentSelection; + } + + public function setCurrentSelection(_val:Number):Void + { + currentSelection = _val; + } + + + +} \ No newline at end of file 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; + } + +//-------------------------------------------------------------------------------------------- + +} -- cgit v1.2.3-70-g09d2