home *** CD-ROM | disk | FTP | other *** search
- package ENGINE.INTERFACE
- {
- import ENGINE.CORE.OGlobal;
- import ENGINE.INTERFACE.ANIMATORS.*;
- import ENGINE.INTERFACE.ELEMENTS.OListBoxElement;
- import flash.events.*;
-
- public class OListBox extends OIObject
- {
-
- public static const iDefAnimators:Array = [{
- "F":OA_Alpha.Make,
- "iSAlpha":0,
- "iEAlpha":1,
- "iPIter":6
- },{
- "F":OA_Alpha.Make,
- "iSAlpha":-1,
- "iEAlpha":0,
- "iPIter":6
- },{
- "F":OA_Alpha.Make,
- "iSAlpha":-1,
- "iEAlpha":1,
- "iPIter":6
- },{
- "F":OA_Alpha.Make,
- "iSAlpha":-1,
- "iEAlpha":0.2,
- "iPIter":6
- },null,null,{
- "F":OA_AlphaInd.Make,
- "iSAlpha":-1,
- "iEAlpha":0.6,
- "iInd":[0],
- "iPIter":6
- },{
- "F":OA_AlphaInd.Make,
- "iSAlpha":-1,
- "iEAlpha":1,
- "iInd":[0],
- "iPIter":6
- },null,null];
-
-
- private var iLBParams:Array;
-
- private var iEGenP:Function;
-
- private var iElements:Array;
-
- public var iDown:OButton;
-
- private var iEGen:Array;
-
- public var iUp:OButton;
-
- private var iEShowInd:int;
-
- private var iSelection:Boolean = true;
-
- private var iECoord:Array;
-
- private var iECount:int;
-
- private var iCycling:Boolean;
-
- private var iECurInd:int;
-
- private var iPageScrool:Boolean;
-
- public function OListBox(param1:Array, param2:Array, param3:Function, param4:Array, param5:Array, param6:Array = null)
- {
- var _loc7_:Array = null;
- iSelection = true;
- _loc7_ = !!param6 ? param6 : iDefAnimators;
- this.iEGen = param2;
- this.iEGenP = param3;
- this.iECoord = param4;
- this.iLBParams = param5;
- this.iECount = this.iECoord.length;
- super(param1,_loc7_);
- }
-
- public function SetCurrentElement(param1:*, param2:Array = null) : void
- {
- var _loc3_:int = 0;
- if(!param1 && !param2)
- {
- this.FreeElements();
- this.iLBParams = null;
- this.iECurInd = 0;
- this.iEShowInd = 0;
- return;
- }
- if(param2)
- {
- this.iLBParams = param2;
- }
- if(!this.iLBParams)
- {
- return;
- }
- this.iECurInd = 0;
- _loc3_ = 0;
- while(_loc3_ < this.iLBParams.length)
- {
- if(param1 == this.iLBParams[_loc3_])
- {
- this.iECurInd = _loc3_;
- break;
- }
- _loc3_++;
- }
- this.iEShowInd = this.iECurInd;
- if(this.iEShowInd + this.iECount >= this.iLBParams.length)
- {
- this.iEShowInd = this.iLBParams.length - this.iECount;
- }
- if(this.iEShowInd < 0)
- {
- this.iEShowInd = 0;
- }
- InitElements();
- }
-
- protected function UnpressElements(param1:OListBoxElement) : void
- {
- var _loc2_:int = 0;
- _loc2_ = 0;
- while(_loc2_ < this.iElements.length)
- {
- if(this.iElements[_loc2_])
- {
- if(this.iElements[_loc2_] == param1)
- {
- this.iECurInd = this.iEShowInd + _loc2_;
- }
- else if(this.iElements[_loc2_].prPress)
- {
- this.iElements[_loc2_].prPress = false;
- }
- }
- _loc2_++;
- }
- }
-
- public function get prPageScrool() : Boolean
- {
- return this.iPageScrool;
- }
-
- protected function InitElements() : void
- {
- var _loc1_:int = 0;
- var _loc2_:int = 0;
- var _loc3_:int = 0;
- var _loc4_:Boolean = false;
- this.FreeElements();
- if(this.iLBParams == null)
- {
- return;
- }
- _loc1_ = 0;
- _loc2_ = this.iEShowInd + this.iECount <= this.iLBParams.length ? this.iEShowInd + this.iECount : int(this.iLBParams.length);
- _loc3_ = this.iEShowInd;
- while(_loc3_ < _loc2_)
- {
- this.iEGenP(this.iEGen,this.iLBParams[_loc3_]);
- this.iElements[_loc1_] = this.iEGen[0](this.iEGen);
- this.iElements[_loc1_].Pos(OGlobal.ScaleFloor(this.iECoord[_loc1_][0]),OGlobal.ScaleFloor(this.iECoord[_loc1_][1]));
- this.iElements[_loc1_].mouseEnabled = this.iSelection;
- this.addChild(this.iElements[_loc1_]);
- if(this.iECurInd == _loc3_ && this.iSelection)
- {
- this.iElements[_loc1_].prPress = true;
- }
- _loc1_++;
- _loc3_++;
- }
- if(Boolean(this.iUp) && Boolean(this.iDown))
- {
- if(this.iCycling)
- {
- _loc4_ = !!this.iLBParams ? this.iLBParams.length > this.iECount : false;
- if(this.iUp.prVisible != _loc4_)
- {
- this.iUp.prVisible = _loc4_;
- }
- if(this.iDown.prVisible != _loc4_)
- {
- this.iDown.prVisible = _loc4_;
- }
- }
- else
- {
- if(this.iEShowInd == 0 && this.iUp.prVisible)
- {
- if(this.iUp.prPress)
- {
- this.iUp.prPress = false;
- }
- this.iUp.prVisible = false;
- }
- if(this.iEShowInd > 0 && !this.iUp.prVisible)
- {
- this.iUp.prVisible = true;
- }
- if(this.iEShowInd + this.iECount >= this.iLBParams.length && this.iDown.prVisible)
- {
- if(this.iDown.prPress)
- {
- this.iDown.prPress = false;
- }
- this.iDown.prVisible = false;
- }
- if(this.iEShowInd + this.iECount < this.iLBParams.length && !this.iDown.prVisible)
- {
- this.iDown.prVisible = true;
- }
- }
- }
- }
-
- public function set prPageScrool(param1:Boolean) : void
- {
- this.iPageScrool = param1;
- }
-
- override public function Free() : void
- {
- this.iUp = null;
- this.iDown = null;
- this.iElements = null;
- super.Free();
- }
-
- public function set prCurrentInd(param1:int) : void
- {
- if(!this.iLBParams)
- {
- return;
- }
- this.SetCurrentElement(this.iLBParams[param1]);
- }
-
- override public function Init() : void
- {
- super.Init();
- this.iElements = new Array();
- this.InitElements();
- }
-
- public function set prLBParams(param1:Array) : void
- {
- this.iLBParams = param1;
- this.iECurInd = 0;
- this.iEShowInd = 0;
- this.InitElements();
- }
-
- public function get prCurrentInd() : int
- {
- return this.iECurInd;
- }
-
- public function set prSelection(param1:Boolean) : void
- {
- this.iSelection = param1;
- InitElements();
- }
-
- public function set prCycling(param1:Boolean) : void
- {
- this.iCycling = param1;
- InitElements();
- }
-
- override public function OnPress(param1:Event, param2:*) : void
- {
- if(param2 is OListBoxElement)
- {
- this.UnpressElements(param2 as OListBoxElement);
- }
- if(param2 == this.iUp && this.SkipElements(this.iPageScrool ? int(-this.iECount) : -1))
- {
- this.InitElements();
- }
- if(param2 == this.iDown && this.SkipElements(this.iPageScrool ? this.iECount : 1))
- {
- this.InitElements();
- }
- if(this.parent is OIObject)
- {
- (this.parent as OIObject).OnPress(param1,this);
- }
- }
-
- public function get prSelection() : Boolean
- {
- return this.iSelection;
- }
-
- protected function FreeElements() : void
- {
- var _loc1_:int = 0;
- _loc1_ = 0;
- while(_loc1_ < this.iElements.length)
- {
- if(this.iElements[_loc1_])
- {
- this.removeChild(this.iElements[_loc1_]);
- this.iElements[_loc1_].Free();
- this.iElements[_loc1_] = null;
- }
- _loc1_++;
- }
- }
-
- protected function SkipElements(param1:int) : Boolean
- {
- var _loc2_:int = 0;
- if(!this.iLBParams)
- {
- return false;
- }
- _loc2_ = this.iEShowInd + param1;
- if(_loc2_ + this.iECount >= this.iLBParams.length)
- {
- _loc2_ = this.iCycling ? _loc2_ - this.iLBParams.length : this.iLBParams.length - this.iECount;
- }
- if(_loc2_ < 0)
- {
- _loc2_ = this.iCycling ? this.iLBParams.length + _loc2_ : 0;
- }
- if(this.iEShowInd == _loc2_)
- {
- return false;
- }
- this.iEShowInd = _loc2_;
- if(!this.iSelection)
- {
- this.iECurInd = this.iEShowInd;
- }
- return true;
- }
-
- public function get prCurrentLBParam() : *
- {
- return !!this.iLBParams ? this.iLBParams[this.iECurInd] : null;
- }
-
- public function get prCycling() : Boolean
- {
- return this.iCycling;
- }
- }
- }
-