export class GlobalWaiting extends fairygui.GComponent { img_0:fairygui.GImage; private _isforcehide:boolean = false; constructor() { super(); } protected constructFromXML(xml:any):void { this.setSize(fairygui.GRoot.inst.width,fairygui.GRoot.inst.height); super.constructFromXML(xml); this.img_0 = this.getChild("img_0").asImage; this.img_0.visible = false; this.on(Laya.Event.DISPLAY,this,this.onAddedToStage); this.on( Laya.Event.UNDISPLAY,this,this.onRemoveFromStage); } private _lastTime:number = 0; private onAddedToStage():void { this._lastTime = Laya.Browser.now(); Laya.timer.frameLoop(1, this, this.onTimer); } private onTimer():void { if(this.img_0) { var nowtime:number = Laya.Browser.now(); var distime:number = nowtime-this._lastTime; if( distime /1000 >= 0 ) { if( !this._isforcehide ) { this.img_0.visible = true; } var i:number = this.img_0.rotation; i += 10; if(i > 360) i = i % 360; this.img_0.rotation = i; } else { this.img_0.visible = false; } } } public hideimg():void { this._isforcehide = true; if( this.img_0 ) { this.img_0.visible = false; } } private onRemoveFromStage():void { Laya.timer.clear(this, this.onTimer); } }