home *** CD-ROM | disk | FTP | other *** search
- package com.livebrush.tools
- {
- import com.livebrush.data.Settings;
- import com.livebrush.events.CanvasEvent;
- import flash.events.Event;
- import flash.events.MouseEvent;
-
- public class SampleTool extends Tool
- {
- public static const NAME:String = "sampleTool";
-
- public static const KEY:String = "E";
-
- private var allLayers:Boolean = true;
-
- private var color:uint;
-
- private var updateColor:Boolean;
-
- public function SampleTool(toolMan:ToolManager)
- {
- super(toolMan);
- this.init();
- }
-
- private function setColor() : void
- {
- this.color = canvas.getMouseColor(this.allLayers);
- ui.pushColorProps(this.settings);
- }
-
- override public function set settings(data:Settings) : void
- {
- }
-
- override protected function canvasMouseEvent(e:CanvasEvent) : void
- {
- var mouseEvent:MouseEvent = e.triggerEvent as MouseEvent;
- if(mouseEvent.type == MouseEvent.MOUSE_DOWN)
- {
- this.updateColor = true;
- this.setColor();
- begin();
- }
- if(mouseEvent.type == MouseEvent.MOUSE_UP)
- {
- this.updateColor = false;
- this.setColor();
- finish(false);
- }
- }
-
- private function init() : void
- {
- name = NAME;
- }
-
- override public function get settings() : Settings
- {
- var settings:Settings = new Settings();
- settings.color = this.color;
- return settings;
- }
-
- override protected function enterFrameHandler(e:Event) : void
- {
- if(this.updateColor)
- {
- this.setColor();
- }
- }
- }
- }
-
-