O'Reilly logo

Flash CS5: The Missing Manual by Chris Grover

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 18. Drawing with ActionScript

If you were one of those kids who loved the Etch-A-Sketch, then you’re probably going to love this chapter. With ActionScript, you can draw lines and shapes in your Flash animations. The great advantage of drawing with ActionScript is that your animations can draw new objects on the fly.

This chapter will introduce the Graphics class and all the power it puts at your fingertips. To start with, you’ll learn how ActionScript works with points and lines. You’ll learn about the virtual pen and how, as it moves from one spot to another, you can tell it to draw lines (or not). Then you’ll learn how to draw and display Flash’s built-in shapes, including ellipses, rectangles, and rounded rectangles. There are times when prebuilt shapes won’t do the job, so you’ll see how to draw more complex and irregular shapes using nothing but ActionScript code. To wrap things up, this chapter shows how to move the shapes you’ve drawn about the stage using ActionScript’s TimerEvent to trigger the motion.

What’s the Point?

It all comes down to the point. Flash’s stage is a mass of points measured by x/y coordinates. In the upper-left corner, there’s a point that’s referenced by 0, 0, which means it’s at the 0 point on the horizontal axis and the 0 point of vertical axis. ActionScript describes the point as x = 0 and y = 0. If you put something on the stage and don’t tell Flash or ActionScript where you want to place it, chances are that something will end up at 0, 0. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required