home *** CD-ROM | disk | FTP | other *** search
- package Gamefile
- {
- import flash.display.MovieClip;
- import flash.display.SimpleButton;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import flash.filters.GlowFilter;
-
- public class PencilTool
- {
-
-
- public var PencilMC:MovieClip;
-
- public var drawFlag:Boolean;
-
- private var pencilColor:uint;
-
- private var movingFlag:Boolean;
-
- public var pencilArr:Array;
-
- public const operateType:int = 3;
-
- private var previousBtn:SimpleButton;
-
- private var pencilBtnFilter:GlowFilter;
-
- private var PARENT:MovieClip;
-
- private var _brushBtn_:SimpleButton;
-
- private var pencilSize:int;
-
- public var pencilType:int;
-
- public function PencilTool(param1:MovieClip)
- {
- super();
- initPencilTool(param1);
- }
-
- private function choosePencil(param1:MouseEvent) : *
- {
- if(movingFlag == false)
- {
- SoundsManager.playSound("_GameMouseDown_");
- pencilGlowFilter();
- pencilType = 2;
- PARENT.dispatchEvent(new Event("choosePencil",true));
- }
- }
-
- private function initProperty() : *
- {
- pencilBtnFilter = new GlowFilter(16776960,1,10,10,10,1,false,false);
- pencilType = 0;
- pencilSize = 1;
- pencilArr = new Array();
- drawFlag = false;
- pencilColor = 16737380;
- pencilSize = 10;
- movingFlag = false;
- }
-
- public function delEvent() : *
- {
- _brushBtn_.removeEventListener(MouseEvent.CLICK,choosePencil);
- _brushBtn_.removeEventListener(MouseEvent.MOUSE_OVER,mouseIsOver);
- _brushBtn_.removeEventListener(MouseEvent.MOUSE_OUT,mouseIsOut);
- }
-
- private function initElement() : *
- {
- _brushBtn_ = PARENT.getChildByName("BrushBtn") as SimpleButton;
- }
-
- public function Pencildrawing(param1:int, param2:int) : *
- {
- PencilMC.graphics.lineTo(param1,param2);
- }
-
- public function pencilGlowFilter() : *
- {
- _brushBtn_.filters = [pencilBtnFilter];
- }
-
- public function getMovingFlag(param1:Boolean) : *
- {
- movingFlag = param1;
- }
-
- public function endPencilDraw(param1:MovieClip, param2:Boolean) : *
- {
- if(drawFlag == false)
- {
- param1.removeChild(PencilMC);
- }
- else if(drawFlag == true && param2 == false)
- {
- pencilArr.push(PencilMC);
- pencilArr.push("end");
- PencilMC.y = PencilMC.y;
- drawFlag = false;
- }
- }
-
- private function mouseIsOut(param1:MouseEvent) : *
- {
- PARENT.dispatchEvent(new Event("mouseIsOut",true));
- }
-
- public function setPencilColor(param1:uint) : *
- {
- pencilColor = param1;
- if(PencilMC != null)
- {
- PencilMC.graphics.lineStyle(pencilSize,pencilColor,1);
- }
- }
-
- public function showPencilArr() : *
- {
- var _loc1_:int = 0;
- _loc1_ = 0;
- while(_loc1_ < pencilArr.length)
- {
- if(pencilArr[_loc1_] != "end")
- {
- pencilArr[_loc1_].visible = true;
- }
- _loc1_++;
- }
- }
-
- private function mouseIsOver(param1:MouseEvent) : *
- {
- if(movingFlag == true)
- {
- PARENT.dispatchEvent(new Event("mouseIsNotEnabled",true));
- }
- else
- {
- SoundsManager.playSound("_GameMouseOver_");
- PARENT.dispatchEvent(new Event("mouseIsOver",true));
- }
- }
-
- private function initEvent() : *
- {
- _brushBtn_.addEventListener(MouseEvent.CLICK,choosePencil);
- _brushBtn_.addEventListener(MouseEvent.MOUSE_OVER,mouseIsOver);
- _brushBtn_.addEventListener(MouseEvent.MOUSE_OUT,mouseIsOut);
- }
-
- public function hidePencilArr() : *
- {
- var _loc1_:int = 0;
- _loc1_ = 0;
- while(_loc1_ < pencilArr.length)
- {
- if(pencilArr[_loc1_] != "end")
- {
- pencilArr[_loc1_].visible = false;
- }
- _loc1_++;
- }
- }
-
- private function initPencilTool(param1:MovieClip) : *
- {
- PARENT = param1;
- initElement();
- initEvent();
- initProperty();
- }
-
- public function clearBtnFilters() : *
- {
- _brushBtn_.filters = [];
- }
-
- public function createPencilMC(param1:MovieClip, param2:int, param3:int, param4:Number) : *
- {
- PencilMC = new MovieClip();
- param1.addChild(PencilMC);
- setPencilColor(param4);
- PencilMC.graphics.moveTo(param2,param3);
- }
- }
- }
-