|
|
Creating a Simple Drawing Pad Also posted on Knol: Drawing with a mouse ActionScript3 Summary How to create a drawing pad in Flash and ActionScript 3. The steps are: Listen for MouseDown events to toggle the drawing mode on or off. Listen for MouseMove events and draw a line if the drawing mode is set. Flash Code (Cut and paste the code below into your 'actions' window, Window -> Actions. To execute, Control -> Test Movie) Drawing pad An additional and important enhancement for the drawing pad is to render the vector lines to a bitmap image. usually in other languages this is known as blitting or blit. If we don't do this, the longer we keep creating more lines the slower and slower the Flash app becomes (or the more CPU it takes). It would be busy creating multiple lines per redraw. This is done in Flash using the BitmapData object and using the method draw. .. // Create the Bitmap object, add to stage var bmpdata:BitmapData = new BitmapData(550, 400); var bmp:Bitmap = new Bitmap(bmpdata); addChild(bmp); // Copy the sprite to the bitmap bmpdata.draw(penSprite); .. |
||
| |||||||||||||||||||||