Chapter 22. Building a Flash Paint Application

Flash MX offers many possibilities for dynamically generating vector graphics and text using ActionScript. In this chapter, you will create a Flash Paint application. This application builds on many of the recipes from earlier chapters. Specifically, this application utilizes the following skills:

  • Drawing and filling shapes with the Drawing API

  • Developing and using custom components

  • Extending classes

  • Swapping depths of movie clips and text fields

  • Using mouse and key listeners

  • Changing colors of movie clips

  • Getting and setting the current focus and selection

The Flash Paint application is designed to allow for the following functionality:

  • Drawing lines, rectangles, and ellipses

  • Adding text fields

  • Rearranging existing shapes and text

  • Moving existing shapes and text forward or backward to adjust the overlap with other objects

  • Selecting a color to apply to new text and with which to draw shapes

  • Filling existing shapes with solid color and applying color to existing text

  • Deleting existing shapes and text

Planning the Application

You should begin designing the Flash Paint application by determining the necessary elements and mapping out how they should work together. The list of desired functionality in the previous section gives you a good idea of which elements you will need to develop. Essentially, there are four basic elements:

Toolbar buttons

These are the buttons that allow the user to select which type of action to take, be it selecting items, drawing ...

Get Actionscript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.