home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / Never_End.swf / scripts / game / Button.as < prev    next >
Encoding:
Text File  |  2008-09-23  |  1.7 KB  |  74 lines

  1. package game
  2. {
  3.    import flash.display.MovieClip;
  4.    import flash.events.MouseEvent;
  5.    import flash.text.TextField;
  6.    
  7.    public class Button extends MovieClip
  8.    {
  9.        
  10.       
  11.       private var toogle:Boolean = false;
  12.       
  13.       public var txt:TextField;
  14.       
  15.       public function Button()
  16.       {
  17.          toogle = false;
  18.          super();
  19.          this.mouseChildren = false;
  20.          this.buttonMode = true;
  21.          this.addEventListener(MouseEvent.MOUSE_OVER,onOver);
  22.          this.addEventListener(MouseEvent.MOUSE_UP,onUp);
  23.          this.addEventListener(MouseEvent.MOUSE_DOWN,onDown);
  24.          this.addEventListener(MouseEvent.MOUSE_OUT,onOut);
  25.       }
  26.       
  27.       private function onDown(param1:MouseEvent) : void
  28.       {
  29.          if(!toogle)
  30.          {
  31.             SoundManager.getInstance().playSound("btnDown",SoundManager.TYPE_BTN);
  32.             this.gotoAndPlay("down");
  33.          }
  34.       }
  35.       
  36.       public function setToogle(param1:Boolean) : void
  37.       {
  38.          if(param1)
  39.          {
  40.             this.gotoAndPlay("down");
  41.          }
  42.          else
  43.          {
  44.             this.gotoAndPlay("up");
  45.          }
  46.          toogle = param1;
  47.       }
  48.       
  49.       private function onOver(param1:MouseEvent) : void
  50.       {
  51.          if(!toogle)
  52.          {
  53.             this.gotoAndPlay("over");
  54.          }
  55.       }
  56.       
  57.       private function onUp(param1:MouseEvent) : void
  58.       {
  59.          if(!toogle)
  60.          {
  61.             this.gotoAndPlay("up");
  62.          }
  63.       }
  64.       
  65.       private function onOut(param1:MouseEvent) : void
  66.       {
  67.          if(!toogle)
  68.          {
  69.             this.gotoAndPlay("up");
  70.          }
  71.       }
  72.    }
  73. }
  74.