export class LightComponent extends eui.Component{

    public image:eui.Image;
    public image5:eui.Image;
    public image7:eui.Image;
    public image6:eui.Image;
    public image0:eui.Image;
    public image1:eui.Image;
    public image2:eui.Image;
    public image3:eui.Image;
    public image4:eui.Image;
    

   
    //点击收取回调
    private clickCallBack:Function;
    
    /**
     * 
     */
    constructor(callBack:Function = null){
        super();
        this.skinName       = 'resource/skins/item/lightSkin.exml';
        this.clickCallBack  = callBack;
        this.addEventListener(egret.Event.COMPLETE, this.onSkinComplete, this);
        if (this.skin) {
            this.onSkinComplete();
        }
    }

    private onSkinComplete():void{
        //this.image.visible=false;
        // setTimeout(()=>{
        //     this.image.visible=true;
        //     this["loop"].play(0)
        //     this["loop"].items.forEach((item) => {
        //         item.tween.loop = true;
        //     })
        // },1000*Math.random())
        this.setAnimate(2)
        this.removeEventListener(egret.Event.COMPLETE, this.onSkinComplete, this);
    }

    setAnimate(lv){
        // var tw = egret.Tween.get( target );
        // tw.to( {x:1500}, 1000 );
        for(let i=0;i<8;i++){
            var tw = egret.Tween.get( this[`image${i}`], { loop:true} );
            tw.wait( 1000*Math.random() )
            .to( {scaleX:1,scaleY:1}, 1000 )
            .to( {scaleX:.8,scaleY:.8}, 1000 )  
        }
        
    }

    public removeEvent():void{

    }

    private onClick():void{
        if(this.clickCallBack){
            this.clickCallBack(this);
        }
    }
    
    public playAct(start:number = 0):void{
        
    }

    public stopAct():void{
        // this.act.stop();
    }
}