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 / ToolbarController.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  2.5 KB  |  87 lines

  1. package com.livebrush.ui
  2. {
  3.    import flash.display.Sprite;
  4.    import flash.events.MouseEvent;
  5.    
  6.    public class ToolbarController extends UIController
  7.    {
  8.       public function ToolbarController(toolbarView:ToolbarView)
  9.       {
  10.          super(toolbarView);
  11.          this.init();
  12.       }
  13.       
  14.       private function get toolbarView() : ToolbarView
  15.       {
  16.          return ToolbarView(view);
  17.       }
  18.       
  19.       override protected function init() : void
  20.       {
  21.          for(var i:int = 0; i < this.toolBtns.length; i++)
  22.          {
  23.             this.toolBtns[i].doubleClickEnabled = true;
  24.             this.toolBtns[i].getChildAt(0).doubleClickEnabled = true;
  25.             this.toolBtns[i].mouseEnabled = true;
  26.             this.toolBtns[i].addEventListener(MouseEvent.DOUBLE_CLICK,this.mouseEvent);
  27.             this.toolBtns[i].addEventListener(MouseEvent.MOUSE_DOWN,this.mouseEvent);
  28.          }
  29.          this.toolbarAsset.addEventListener(MouseEvent.CLICK,this.mouseEvent);
  30.       }
  31.       
  32.       private function mouseEvent(e:MouseEvent) : void
  33.       {
  34.          if(e.type == MouseEvent.DOUBLE_CLICK)
  35.          {
  36.             if(e.target.parent.name.indexOf("Btn") > -1 || e.target.name.indexOf("Btn") > -1)
  37.             {
  38.                ui.toggleToolProps();
  39.             }
  40.          }
  41.          else if(e.type == MouseEvent.CLICK)
  42.          {
  43.             if(e.target.name == "lockColorBtn")
  44.             {
  45.                e.target.parent.gotoAndStop(2);
  46.                ui.styleManager.lockColors(true);
  47.             }
  48.             else if(e.target.name == "unlockColorBtn")
  49.             {
  50.                e.target.parent.gotoAndStop(1);
  51.                ui.styleManager.lockColors(false);
  52.             }
  53.             else if(e.target.name == "toggleBtn")
  54.             {
  55.                ui.togglePropsPanel();
  56.             }
  57.             else if(e.target.name == "_colorBg")
  58.             {
  59.                ui.toggleGlobalColor();
  60.             }
  61.             else if(e.target.name == "helpBtn")
  62.             {
  63.                _loadHelp();
  64.             }
  65.          }
  66.          else if(e.type == MouseEvent.MOUSE_DOWN)
  67.          {
  68.             if(e.target.parent.name.indexOf("Btn") > -1)
  69.             {
  70.                ui.toolSelect(e.target.parent.toolName);
  71.             }
  72.          }
  73.       }
  74.       
  75.       private function get toolbarAsset() : Sprite
  76.       {
  77.          return this.toolbarView.toolbarAsset;
  78.       }
  79.       
  80.       private function get toolBtns() : Array
  81.       {
  82.          return this.toolbarView.toolBtns;
  83.       }
  84.    }
  85. }
  86.  
  87.