home *** CD-ROM | disk | FTP | other *** search
/ Neil's C++ Stuff / 2016-02-neilstuff-weebly.iso / apps / audioPlayer2.swf / scripts / __Packages / Control.as < prev    next >
Encoding:
Text File  |  2016-02-05  |  2.1 KB  |  90 lines

  1. class Control extends MovieClip
  2. {
  3.    var state;
  4.    var pause_mc;
  5.    var play_mc;
  6.    var realWidth;
  7.    var background_mc;
  8.    var broadcastMessage;
  9.    function Control()
  10.    {
  11.       super();
  12.       AsBroadcaster.initialize(this);
  13.       if(this.state == "play")
  14.       {
  15.          this.pause_mc._visible = false;
  16.       }
  17.       else
  18.       {
  19.          this.play_mc._visible = false;
  20.       }
  21.       this.realWidth = this.background_mc._width;
  22.       this.background_mc.hover_mc._visible = this.play_mc.hover_mc._visible = this.pause_mc.hover_mc._visible = false;
  23.    }
  24.    function onRollOver()
  25.    {
  26.       this._switch(true);
  27.    }
  28.    function onRollOut()
  29.    {
  30.       this._switch(false);
  31.    }
  32.    function onReleaseOutside()
  33.    {
  34.       this._switch(false);
  35.    }
  36.    function onRelease()
  37.    {
  38.       this.toggle(true);
  39.    }
  40.    function _switch(toggle)
  41.    {
  42.       if(this.state == "play")
  43.       {
  44.          this.play_mc.hover_mc._visible = toggle;
  45.       }
  46.       if(this.state == "pause")
  47.       {
  48.          this.pause_mc.hover_mc._visible = toggle;
  49.       }
  50.       this.background_mc.hover_mc._visible = toggle;
  51.    }
  52.    function toggle(broadcast)
  53.    {
  54.       if(broadcast == undefined)
  55.       {
  56.          broadcast = false;
  57.       }
  58.       if(this.state == "play")
  59.       {
  60.          if(broadcast)
  61.          {
  62.             this.broadcastMessage("onPlay");
  63.          }
  64.          this.play_mc._visible = false;
  65.          this.play_mc.hover_mc._visible = false;
  66.          this.pause_mc._visible = true;
  67.          this.state = "pause";
  68.       }
  69.       else
  70.       {
  71.          if(broadcast)
  72.          {
  73.             this.broadcastMessage("onPause");
  74.          }
  75.          this.pause_mc._visible = false;
  76.          this.pause_mc.hover_mc._visible = false;
  77.          this.play_mc._visible = true;
  78.          this.state = "play";
  79.       }
  80.    }
  81.    function flip()
  82.    {
  83.       this.background_mc._rotation = 180;
  84.       this.background_mc._y += this.background_mc._height;
  85.       this.background_mc._x += this.background_mc._width;
  86.       this.play_mc._x = 14;
  87.       this.pause_mc._x = 13;
  88.    }
  89. }
  90.