import {GamePool} from "../PrefabControl/GamePool";
import Sprite = Laya.Sprite;
import Event = Laya.Event;
/*
* name;
*/
export class LocalData extends Laya.EventDispatcher
{   
    static ResDicValue:string = "LocalData";

    private logger:Laya.Text;
    /**
     * 引用次数
     */
    ref:number = 0;

    private createCoralRect(): void {
        var coralRect: Sprite = new Sprite();
        coralRect.graphics.drawRect(0, 0, Laya.stage.width, Laya.stage.height / 2, "#FF7F50");

        //设置名称
        coralRect.name = "珊瑚色容器";
        coralRect.size(Laya.stage.width, Laya.stage.height / 2);
        Laya.stage.addChild(coralRect);

        coralRect.on(Event.MOUSE_DOWN, this, this.onDown);
    }

    private createDeepSkyblueRect(): void {
        var deepSkyblueRect: Sprite = new Sprite();
        deepSkyblueRect.graphics.drawRect(0, 0, 100, 100, "#00BFFF");
        //设置名称
        deepSkyblueRect.name = "天蓝色矩形";
        //设置宽高（要接收鼠标事件必须设置宽高，否则不会被命中）  
        deepSkyblueRect.size(100, 100);
        deepSkyblueRect.pos(10, 10);
        Laya.stage.addChild(deepSkyblueRect);

        deepSkyblueRect.on(Event.MOUSE_DOWN, this, this.onDown);
    }
    
    /**
     * 最后一次被引用的时间
     */
    time:number = 0;

    /**
     * 包名
     */
    packageName:string = "";

    public clear():void
    {
        this.ref = 0;
        this.time = 0;
        this.packageName = "";
        GamePool.RemoveItem( LocalData.ResDicValue,this );
    }

    /**侦听处理方法*/
		private onDown(e: Event): void {
			this.logger.text += "点击 - " + e.target.name + "\n";
		}
}