Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Usability

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

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.

  • + Share This
  • 🔖 Save To Your Account