- Initializing the Paint Program
- Creating the Sliding Color Chooser
- Scripting the Tool Buttons
- Scripting the Paint Tools
- How It Works
Scripting the Tool Buttons
SpacePainter features six different tools, plus a Reset button. When pressed, each of the tool buttons sets a variable named ToolType to a different text value to reflect which tool is currently active. The drawing scripts created in the next section control their behavior and then use this text value. Each of the tools and the Reset button are prescripted for convenience, and the code is displayed in Figures 13 through 19.
Figure 13 Paint tool and script.
Figure 14 Line tool and script.
Figure 15 Pen tool and script.
Figure 16 Ellipse tool and script.
Figure 17 Eraser tool and script.
Figure 18 Rectangle tool and script.
Figure 19 Reset button and script.
Here's a quick recap of what's been achieved so far. You've created color objects and number conversion tables for altering the appearance of shapes, picture elements, and the current color display. You hid the mouse cursor and attached an instance of the Pointer symbol to the Stage, setting it to await instructions to follow the mouse. You created a Reset function to delete other visitor-drawn shapes and to return the color of the picture elements to white. Finally, you scripted and activated the color sliders and all the tool buttons.