Skip to Content
Flash CS5: The Missing Manual
book

Flash CS5: The Missing Manual

by Chris Grover
May 2010
Intermediate to advanced
778 pages
23h 58m
English
O'Reilly Media, Inc.
Content preview from Flash CS5: The Missing Manual

Drawing Lines

Think about the steps you take when you draw a line in the real world. You probably have your piece of paper in front of you. You pick up a pen, pencil, or marker. You place the writing instrument down on a specific point on the paper and drag it to another point. If you don't want to continue with another line, you pick up your pen and the job is done. You pretty much follow those same steps when you draw a line using ActionScript. Here's a list of the ActionScript steps:

  • Open a Flash document and the Actions panel. The stage is your paper.

  • Choose a line style. It's similar to choosing a pen, pencil, or whatever.

  • Move to a specific point on the stage. Here's where you put pen to paper.

  • Move to another point, drawing a line in the process, dragging the pen across the paper.

  • Stop drawing lines. Lift the pen from the paper.

Note

The code for the next line-drawing exercise is included in 18-2_Draw_Line.fla in the Missing CD (www.missingmanuals.com/cds).

With those generalizations in mind, here are the specific steps to draw a line on the Flash stage:

  1. Select File→New and choose ActionScript 3.0.

    A new, empty Flash document appears.

  2. Press F9 (Option-F9 on a Mac).

    The Actions window opens, where you can enter ActionScript code.

  3. In the Actions panel, create an instance of the Sprite class by typing the following.

    var sprtLine:Sprite = new Sprite();

    A Sprite is a container like a MovieClip, except it doesn't have a timeline. Using a Sprite instead of a MovieClip when you don't need a timeline ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Flash CS4: The Missing Manual

Flash CS4: The Missing Manual

Chris Grover

Publisher Resources

ISBN: 9781449380267Errata Page