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 / tools / SampleTool.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  1.8 KB  |  75 lines

  1. package com.livebrush.tools
  2. {
  3.    import com.livebrush.data.Settings;
  4.    import com.livebrush.events.CanvasEvent;
  5.    import flash.events.Event;
  6.    import flash.events.MouseEvent;
  7.    
  8.    public class SampleTool extends Tool
  9.    {
  10.       public static const NAME:String = "sampleTool";
  11.       
  12.       public static const KEY:String = "E";
  13.       
  14.       private var allLayers:Boolean = true;
  15.       
  16.       private var color:uint;
  17.       
  18.       private var updateColor:Boolean;
  19.       
  20.       public function SampleTool(toolMan:ToolManager)
  21.       {
  22.          super(toolMan);
  23.          this.init();
  24.       }
  25.       
  26.       private function setColor() : void
  27.       {
  28.          this.color = canvas.getMouseColor(this.allLayers);
  29.          ui.pushColorProps(this.settings);
  30.       }
  31.       
  32.       override public function set settings(data:Settings) : void
  33.       {
  34.       }
  35.       
  36.       override protected function canvasMouseEvent(e:CanvasEvent) : void
  37.       {
  38.          var mouseEvent:MouseEvent = e.triggerEvent as MouseEvent;
  39.          if(mouseEvent.type == MouseEvent.MOUSE_DOWN)
  40.          {
  41.             this.updateColor = true;
  42.             this.setColor();
  43.             begin();
  44.          }
  45.          if(mouseEvent.type == MouseEvent.MOUSE_UP)
  46.          {
  47.             this.updateColor = false;
  48.             this.setColor();
  49.             finish(false);
  50.          }
  51.       }
  52.       
  53.       private function init() : void
  54.       {
  55.          name = NAME;
  56.       }
  57.       
  58.       override public function get settings() : Settings
  59.       {
  60.          var settings:Settings = new Settings();
  61.          settings.color = this.color;
  62.          return settings;
  63.       }
  64.       
  65.       override protected function enterFrameHandler(e:Event) : void
  66.       {
  67.          if(this.updateColor)
  68.          {
  69.             this.setColor();
  70.          }
  71.       }
  72.    }
  73. }
  74.  
  75.