/** * * @author GH * */ class EButton extends eui.Button { /** 是否创建完毕 */ public isCreated: boolean; /** 是否释放了资源 */ public isDisposed: boolean; public bgDisplay: EImage; private _bg: any = null; public constructor() { super(); } public childrenCreated(): void { this.isCreated = true; super.childrenCreated(); this.addOwnEvent(); } protected addOwnEvent(): void { this.addEventListener(egret.TouchEvent.TOUCH_TAP,this.__onBtnTouchTap,this); } protected removeOwnEvent(): void { this.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.__onBtnTouchTap,this); } protected __onBtnTouchTap(evt: egret.TouchEvent): void { // SoundManager.getInstance().playBtm(); } public set bg(value: any) { this._setBg(value); } public _setBg(value: any): void { var self = this; self._bg = value; // if(CommonUtil.isExist(self.bgDisplay)) { // self.bgDisplay.source = value; // } } public get bg(): any { return this._getBg(); } public _getBg(): any { var self = this; // if(CommonUtil.isExist(self.bgDisplay)) { // return self.bgDisplay.source; // } else { // return self._bg; // } } public partAdded(partName: string,instance: any): void { var self = this; super.partAdded(partName,instance); // if(instance == self.bgDisplay && CommonUtil.isExist(self._bg)) { // self.bgDisplay.source = self._bg; // } } public dispose(): void { var self = this; if(self.isDisposed) { return; } self.isDisposed = true; self.isCreated = false; // DisplayUtil.disposeAllui(self); self.removeOwnEvent(); self.removeChildren(); } }