home *** CD-ROM | disk | FTP | other *** search
- package RES.WINDOWS
- {
- import ENGINE.CORE.OUtils;
- import ENGINE.INTERFACE.OButton;
- import ENGINE.INTERFACE.ODialog;
- import ENGINE.INTERFACE.OInput;
- import flash.events.Event;
- import flash.events.KeyboardEvent;
-
- public class OWEnterName extends ODialog
- {
-
-
- public var iCancel:OButton;
-
- private var iHasCancel:Boolean;
-
- public var iName:OInput;
-
- public var iAccept:OButton;
-
- public function OWEnterName(param1:Boolean = true)
- {
- this.iHasCancel = param1;
- super(ClusterzL.OWEnterName);
- }
-
- private function SetNameFocus() : void
- {
- if(!this.stage)
- {
- return;
- }
- if(this.stage.focus == this.iName.iText)
- {
- return;
- }
- this.iName.iText.setSelection(this.iName.iText.length,this.iName.iText.length);
- this.stage.focus = this.iName.iText;
- }
-
- override public function Init() : void
- {
- super.Init();
- this.iName.prText = !!ClusterzL.iGAME.prPlayerName ? ClusterzL.iGAME.prPlayerName : "";
- if(!this.iHasCancel)
- {
- this.iCancel.visible = false;
- this.iAccept.prX = 155;
- }
- this.iName.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);
- }
-
- public function set prName(param1:String) : void
- {
- this.iName.prText = param1;
- }
-
- override public function OnPress(param1:Event, param2:*) : void
- {
- var _loc3_:String = null;
- var _loc4_:String = null;
- if(!this.prMouseEnabled)
- {
- return;
- }
- if(param2 == this.iCancel)
- {
- if(!this.iCancel.visible)
- {
- return;
- }
- this.prVisible = false;
- return;
- }
- if(param2 == this.iAccept)
- {
- _loc3_ = OUtils.ClearString(this.iName.prText.toUpperCase());
- if((_loc4_ = removeSpaces(_loc3_)).length > 0)
- {
- ClusterzL.iGAME.prPlayerName = _loc4_;
- this.prVisible = false;
- }
- else
- {
- this.iName.prText = "";
- }
- }
- }
-
- override public function Free() : void
- {
- super.Free();
- this.iName.removeEventListener(KeyboardEvent.KEY_DOWN,keyHandler);
- this.iName = null;
- this.iAccept = null;
- this.iCancel = null;
- }
-
- public function get prName() : String
- {
- return this.iName.prText;
- }
-
- override public function OnEnterFrame(param1:Event) : void
- {
- super.OnEnterFrame(param1);
- SetNameFocus();
- }
-
- private function removeSpaces(param1:String) : String
- {
- var _loc2_:String = null;
- var _loc3_:int = 0;
- _loc2_ = "";
- _loc3_ = 0;
- while(_loc3_ < param1.length)
- {
- if(param1.charAt(_loc3_) != " ")
- {
- _loc2_ += param1.charAt(_loc3_);
- }
- _loc3_++;
- }
- return _loc2_;
- }
-
- private function keyHandler(param1:KeyboardEvent) : void
- {
- switch(param1.keyCode)
- {
- case 13:
- OnPress(param1,this.iAccept);
- break;
- case 27:
- OnPress(param1,this.iCancel);
- }
- trace(param1.target + "(" + param1.currentTarget + "): " + param1.keyCode + "/" + param1.charCode);
- }
- }
- }
-