/**
 * UI基类
 */
class UIBaseComponent extends eui.Component {
	constructor() {
		super();
		this.addEventListener(eui.UIEvent.CREATION_COMPLETE, this.bindEvents, this);
		this.addEventListener(eui.UIEvent.CREATION_COMPLETE, this.onCreate, this);
	}

	protected createChildren(): void {
		super.createChildren();
	}
	/**
	 * 绑定事件
	 */
	protected bindEvents(): void {
		this.removeEventListener(eui.UIEvent.CREATION_COMPLETE, this.bindEvents, this);
		Lang.instance.addEventListener(SocketEvent.LANG_CHANGE, this.onLangChange, this);
	}

	/**
	 * 创建完成时调用
	 */
	protected onCreate(): void {
		if (GAME_ISMOBILE) {
			this.currentState = 'h5';
			this.validateNow();
		}
		this.removeEventListener(eui.UIEvent.CREATION_COMPLETE, this.onCreate, this);
	}

	/**
	 * 渲染UI时调用
	 */
	protected render(): void {

	}

	/**
	 * 改变语言时调用
	 */
	protected onLangChange(ev?: egret.Event): void {

	}

	/**
	 * 界面关闭时调用
	 */
	public onClose(): void {
	}

	/**
	 * 关闭此界面
	 */
	close(): void {
		Lang.instance.removeEventListener(eui.UIEvent.CREATION_COMPLETE, this.onLangChange, this);
		UIController.instance.closeView(this);
	}
}