{
  "code": "export var on_off;\r\n(function (on_off) {\r\n    on_off[on_off[\"on\"] = 0] = \"on\";\r\n    on_off[on_off[\"off\"] = 1] = \"off\";\r\n})(on_off || (on_off = {}));\r\nexport class Switch extends Laya.Script {\r\n    constructor() {\r\n        super();\r\n        this.kaiguan = on_off.off;\r\n    }\r\n    onAwake() {\r\n        this.CloseSprite = this.owner.getChildByName(\"close\");\r\n        this.OpenSprite = this.owner.getChildByName(\"open\");\r\n        this.Button = this.owner.getChildByName(\"btn\");\r\n        this.Button.clickHandler = Laya.Handler.create(this, () => {\r\n            this.ChangeMode(this.kaiguan);\r\n            this.kaiguan++;\r\n            if (this.kaiguan > 1) {\r\n                this.kaiguan = 0;\r\n            }\r\n        }, null, false);\r\n    }\r\n    ListenOn_Off(on = true, OpenFunction = null, CloseFunction = null) {\r\n        this.kaiguan = on ? on_off.on : on_off.off;\r\n        this.OpenFunction = OpenFunction;\r\n        this.CloseFunction = CloseFunction;\r\n        this.ChangeMode(this.kaiguan);\r\n        this.kaiguan++;\r\n        if (this.kaiguan > 1) {\r\n            this.kaiguan = 0;\r\n        }\r\n    }\r\n    ChangeMode(_mode) {\r\n        switch (_mode) {\r\n            case on_off.off:\r\n                this.OpenSprite.visible = false;\r\n                this.CloseSprite.visible = true;\r\n                this.CloseFunction.run();\r\n                break;\r\n            case on_off.on:\r\n                this.OpenSprite.visible = true;\r\n                this.CloseSprite.visible = false;\r\n                this.OpenFunction.run();\r\n                break;\r\n        }\r\n    }\r\n}\r\n//# sourceMappingURL=Switch.js.map",
  "references": [],
  "map": "{\"version\":3,\"file\":\"Switch.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../src/Tool/Switch.ts\"],\"names\":[],\"mappings\":\"AAAA,MAAM,CAAN,IAAY,MAAiB;AAA7B,WAAY,MAAM;IAAE,+BAAE,CAAA;IAAE,iCAAG,CAAA;AAAC,CAAC,EAAjB,MAAM,KAAN,MAAM,QAAW;AAE7B,MAAM,OAAQ,MAAO,SAAQ,IAA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