home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / Livebrush / Install-LivebrushLite.air / livebrush.swf / scripts / com / livebrush / ui / Panel.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  2.7 KB  |  107 lines

  1. package com.livebrush.ui
  2. {
  3.    import com.livebrush.events.ConsolEvent;
  4.    import flash.display.Sprite;
  5.    import flash.events.EventPhase;
  6.    import flash.events.MouseEvent;
  7.    
  8.    public class Panel extends Sprite
  9.    {
  10.       private var _bg:Sprite;
  11.       
  12.       private var _isRemovable:Boolean = true;
  13.       
  14.       public var _label:String = "Panel";
  15.       
  16.       private var _titlebar:PanelTitleBar;
  17.       
  18.       public var helpID:String;
  19.       
  20.       public var isDragable:Boolean = true;
  21.       
  22.       public function Panel()
  23.       {
  24.          super();
  25.       }
  26.       
  27.       private function titlebarDownListener(e:MouseEvent) : void
  28.       {
  29.          if(this.isDragable)
  30.          {
  31.             startDrag();
  32.          }
  33.       }
  34.       
  35.       public function set isRemovable(b:Boolean) : void
  36.       {
  37.          this._isRemovable = this._titlebar.showClose = b;
  38.       }
  39.       
  40.       public function close() : void
  41.       {
  42.          parent.removeChild(this);
  43.       }
  44.       
  45.       private function closeBtnListener(e:MouseEvent) : void
  46.       {
  47.          if(e.eventPhase == EventPhase.AT_TARGET)
  48.          {
  49.             if(this._isRemovable)
  50.             {
  51.                this.close();
  52.             }
  53.          }
  54.       }
  55.       
  56.       public function set label(l:String) : void
  57.       {
  58.          this._titlebar.label.text = this._label = l.toUpperCase();
  59.       }
  60.       
  61.       public function outputToConsol(output:String) : void
  62.       {
  63.          dispatchEvent(new ConsolEvent(ConsolEvent.OUTPUT,true,false,output));
  64.       }
  65.       
  66.       private function helpBtnListener(e:MouseEvent) : void
  67.       {
  68.          if(e.eventPhase == EventPhase.AT_TARGET)
  69.          {
  70.             this.getHelp({
  71.                "context":this.label,
  72.                "id":this.helpID
  73.             });
  74.          }
  75.       }
  76.       
  77.       public function getHelp(o:Object) : void
  78.       {
  79.       }
  80.       
  81.       private function titlebarUpListener(e:MouseEvent) : void
  82.       {
  83.          if(this.isDragable)
  84.          {
  85.             stopDrag();
  86.          }
  87.       }
  88.       
  89.       public function get label() : String
  90.       {
  91.          return this._label;
  92.       }
  93.       
  94.       internal function setup() : void
  95.       {
  96.          this._bg = Sprite(getChildByName("bg"));
  97.          this._titlebar = PanelTitleBar(getChildByName("titlebar"));
  98.          this._titlebar.setWidth(this._bg.width);
  99.          this._titlebar.closeBtn.addEventListener(MouseEvent.CLICK,this.closeBtnListener);
  100.          this._titlebar.helpBtn.addEventListener(MouseEvent.CLICK,this.helpBtnListener);
  101.          this._titlebar.bg.addEventListener(MouseEvent.MOUSE_DOWN,this.titlebarDownListener);
  102.          this._titlebar.bg.addEventListener(MouseEvent.MOUSE_UP,this.titlebarUpListener);
  103.       }
  104.    }
  105. }
  106.  
  107.