home *** CD-ROM | disk | FTP | other *** search
- package classes.basic.Button
- {
- import classes.basic.Events.TFEvent;
- import classes.basic.MovieClip.*;
- import flash.display.MovieClip;
-
- public class TFSwitchButton extends TFButton
- {
-
-
- private var eventHandler:Function;
-
- private var over:Boolean;
-
- public function TFSwitchButton(param1:MovieClip, param2:Function)
- {
- this.over = false;
- this.eventHandler = param2;
- super(param1,onBtnEvent);
- }
-
- private function update() : *
- {
- if(movieClip.out != undefined)
- {
- if(over)
- {
- movieClip.out.visible = false;
- }
- else
- {
- movieClip.out.visible = true;
- }
- }
- if(movieClip.over != undefined)
- {
- if(over)
- {
- movieClip.over.visible = true;
- }
- else
- {
- movieClip.over.visible = false;
- }
- }
- if(movieClip.down != undefined)
- {
- movieClip.down.visible = false;
- }
- if(movieClip.disabled != undefined)
- {
- movieClip.disabled.visible = false;
- }
- }
-
- private function onLoadFrame() : *
- {
- movieClip.stop();
- update();
- }
-
- protected function onBtnEvent(param1:TFEvent) : *
- {
- switch(param1.event)
- {
- case TFEvent.EVENT_MOUSECLICK:
- if(movieClip.currentFrame == 1)
- {
- off();
- }
- else
- {
- on();
- }
- break;
- case TFEvent.EVENT_INIT:
- break;
- case TFEvent.EVENT_MOUSEOUT:
- over = false;
- break;
- case TFEvent.EVENT_MOUSEOVER:
- over = true;
- break;
- default:
- if(eventHandler != null)
- {
- eventHandler(param1);
- }
- }
- }
-
- public function on() : *
- {
- movieClip.gotoAndStop("on");
- TFMovieClip.addLabelScript(movieClip,"on",onLoadFrame);
- if(eventHandler != null)
- {
- eventHandler(new TFEvent(TFEvent.EVENT_ON,movieClip));
- }
- }
-
- public function off() : *
- {
- movieClip.gotoAndStop("off");
- TFMovieClip.addLabelScript(movieClip,"off",onLoadFrame);
- if(eventHandler != null)
- {
- eventHandler(new TFEvent(TFEvent.EVENT_OFF,movieClip));
- }
- }
- }
- }
-