{
  "code": "export var SwitchButtonState;\r\n(function (SwitchButtonState) {\r\n    SwitchButtonState[SwitchButtonState[\"Close\"] = 0] = \"Close\";\r\n    SwitchButtonState[SwitchButtonState[\"Open\"] = 1] = \"Open\";\r\n})(SwitchButtonState || (SwitchButtonState = {}));\r\nexport class SwitchButton extends Laya.Script {\r\n    constructor() {\r\n        super();\r\n        this.ButtonState = SwitchButtonState.Close;\r\n    }\r\n    onAwake() {\r\n        this.openSprite = this.owner.getChildByName(\"openSprite\");\r\n        this.closeSprite = this.owner.getChildByName(\"closeSprite\");\r\n        this.button = this.owner.getChildByName(\"button\");\r\n        this.button.clickHandler = Laya.Handler.create(this, () => {\r\n            this.ChangeState(this.ButtonState);\r\n            this.ButtonState++;\r\n            if (this.ButtonState > 1) {\r\n                this.ButtonState = 0;\r\n            }\r\n        }, null, false);\r\n    }\r\n    Init(open = true, _openHandle = null, _closeHnadle = null) {\r\n        this.ButtonState = open ? SwitchButtonState.Open : SwitchButtonState.Close;\r\n        this.openHandle = _openHandle;\r\n        this.closeHandle = _closeHnadle;\r\n        this.ChangeState(this.ButtonState);\r\n        this.ButtonState++;\r\n        if (this.ButtonState > 1) {\r\n            this.ButtonState = 0;\r\n        }\r\n    }\r\n    get CurState() {\r\n        return this.ButtonState;\r\n    }\r\n    ChangeState(_state) {\r\n        switch (this.ButtonState) {\r\n            case SwitchButtonState.Close:\r\n                this.openSprite.visible = false;\r\n                this.closeSprite.visible = true;\r\n                this.closeHandle.run();\r\n                break;\r\n            case SwitchButtonState.Open:\r\n                this.openSprite.visible = true;\r\n                this.closeSprite.visible = false;\r\n                this.openHandle.run();\r\n                break;\r\n        }\r\n    }\r\n}\r\n",
  "references": []
}
