I am building a Flash Paint application. The basic structure is this.
I have two layers namely topLayer_mc and bottomLayer_mc. The actual vector drawing is drawn on the top layer and onmouseUp of the tool, a bitmap copy of the vector graphics on the top layer is taken and added as a bitmap to the bottom layer. The top layer is cleared subsequently. It is working for the pencil tool.
Now I need to create an eraser tool. This is where things get tricky. In the application there is an option to save the image as png, so alpha has top be preserved. So the coventional method of draw a brush using the vector and using the draw method of bitmap will not work. Of course, on a visual level it would work if the brush drawn using the vector is to have the same color as that of the background.
What I need is to excatly erase the pixels.
Now I have created a brush tool using the conventional technique and clearing is possible but what I need is to exactly erase the pixels. Is there some technique to draw this ?
This is the code that I am using:
I have also uploaded the swf and source code,
http://bobbythecoder.blogspot.com/2011/04/doubt-bitmap.html
When trying out, please draw all over the stage using the pencil (press Pencil button and start drawing)
The source fla is also provided,
http://www.easy-share.com/1914823453/Paint Brush Expt.fla
I have been trying hard for some time so it would be greatly appreciated if you can assist.
topLayer_mc and bottomLayer_mc have alpha set to zero now.
I have also not created a draggable brush, just two hard coded positions are cleared. To draw using pencil, just press the pencil button and draw. To clear, just press the eraser button.
What I need is a technique to erase the pixels in the area marked by a brush not just drawing over it.