header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
MKiran
Points:120
Posts:11

8/28/2010 10:46:40 AM

Title: Pen and Eraser tool in Flex


Can any one help me to develop Pen and Eraser tools in Flex......

Please help me....

Thanks in Advance



1
Ronald
Points: 430
Posts:0
8/28/2010 11:08:11 AM



to create a pen tool in flash you can use the graphics class , see the following code. The below code just draw line from one point to the next as the mouse moves. on mouse down we start the drawing code and on release stop the drawing code. Actually we cannot erase a line but the work around is to set the line color to white. When you draw a white line over your black it will look like erased.



init();
stop();
//
function init() {
   initDrawing();
   initMouse();
}
function initDrawing() {
   createEmptyMovieClip("draw_mc", 10);
   draw_mc.lineStyle(2, 0x000000);
   createEmptyMovieClip("temp_mc", 20);
}
function initMouse() {
   mouseMoveListener = new Object();
   mouseMoveListener.onMouseMove = function() {
      mouseMoveEvent();
   };
   //
   mouseClickListener = new Object();
   mouseClickListener.onMouseDown = function() {
      mouseDownEvent();
   };
   mouseClickListener.onMouseUp = function() {
      mouseUpEvent();
   };
   Mouse.addListener(mouseClickListener);
}
function mouseDownEvent() {
   draw_mc.moveTo(_xmouse, _ymouse);
   Mouse.addListener(mouseMoveListener);
}
function mouseUpEvent() {
   temp_mc.clear();
   Mouse.removeListener(mouseMoveListener);
}
function mouseMoveEvent() {
   // Remove any previous drawing
   temp_mc.clear();
   // Draw dot at End Point
   temp_mc.lineStyle(6, 0x00ff00);
   temp_mc.moveTo(_xmouse, _ymouse);
   temp_mc.lineTo(_xmouse + 0.5, _ymouse);
   // Draw line segment
   draw_mc.lineTo(_xmouse, _ymouse);
}


2
Flash_Guy
Points: 850
Posts:0
8/28/2010 11:11:12 AM



check this link for creating freehand drawing or pen tool using actionscript 3
http://www.flashandmath.com/basic/mousedraw2/index.html


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 4+8 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions