| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- function CGfxButton(iXPos,iYPos,oSprite,bAdd){
-
- var _aCbCompleted;
- var _aCbOwner;
- var _oButton;
-
- this._init =function(iXPos,iYPos,oSprite,bAdd){
-
- _aCbCompleted=new Array();
- _aCbOwner =new Array();
-
- _oButton = createBitmap( oSprite);
- _oButton.x = iXPos;
- _oButton.y = iYPos;
-
- _oButton.regX = oSprite.width/2;
- _oButton.regY = oSprite.height/2;
- _oButton.cursor = "pointer";
- if(bAdd){
- s_oStage.addChild(_oButton);
- }
-
- this._initListener();
- };
-
- this.unload = function(){
- _oButton.off("mousedown");
- _oButton.off("pressup");
-
- s_oStage.removeChild(_oButton);
- };
-
- this.setVisible = function(bVisible){
- _oButton.visible = bVisible;
- };
-
- this._initListener = function(){
- oParent = this;
- _oButton.on("mousedown", this.buttonDown);
- _oButton.on("pressup" , this.buttonRelease);
- };
-
- this.addEventListener = function( iEvent,cbCompleted, cbOwner ){
- _aCbCompleted[iEvent]=cbCompleted;
- _aCbOwner[iEvent] = cbOwner;
- };
-
- this.buttonRelease = function(){
- _oButton.scaleX = 1;
- _oButton.scaleY = 1;
-
- playSound("click",1,false);
-
- if(_aCbCompleted[ON_MOUSE_UP]){
- _aCbCompleted[ON_MOUSE_UP].call(_aCbOwner[ON_MOUSE_UP]);
- }
- };
-
- this.buttonDown = function(){
- _oButton.scaleX = 0.9;
- _oButton.scaleY = 0.9;
- if(_aCbCompleted[ON_MOUSE_DOWN]){
- _aCbCompleted[ON_MOUSE_DOWN].call(_aCbOwner[ON_MOUSE_DOWN]);
- }
- };
-
- this.setPosition = function(iXPos,iYPos){
- _oButton.x = iXPos;
- _oButton.y = iYPos;
- };
-
- this.setX = function(iXPos){
- _oButton.x = iXPos;
- };
-
- this.setY = function(iYPos){
- _oButton.y = iYPos;
- };
-
- this.getButtonImage = function(){
- return _oButton;
- };
-
-
- this.getX = function(){
- return _oButton.x;
- };
-
- this.getY = function(){
- return _oButton.y;
- };
- this._init(iXPos,iYPos,oSprite,bAdd);
-
- return this;
- }
|