Skip to Main Content
Essential ActionScript 3.0
book

Essential ActionScript 3.0

by Colin Moock
June 2007
Intermediate to advanced content levelIntermediate to advanced
948 pages
27h 2m
English
O'Reilly Media, Inc.
Content preview from Essential ActionScript 3.0

Chapter 25. Drawing with Vectors

In ActionsScript, primitive vectors, lines, and shapes are drawn via the Graphics class. However, the Graphics class is never instantiated directly; instead, each ActionScript class that supports programmatic vector drawing creates a Graphics instance automatically and provides access to it via the instance variable graphics. The display classes that support vector drawing are Sprite, MovieClip, and Shape.

Tip

Shape objects consume less memory than Sprite and MovieClip objects. Hence, to conserve memory, vector content should be drawn in Shape objects whenever the containment and interactive capabilities of the Sprite and MovieClip classes are not required.

Graphics Class Overview

As shown in Table 25-1, the Graphics class’s drawing tools can be broken down into five general categories: drawing lines, drawing shapes (also known as fills), defining line styles, moving the drawing pen, and removing graphics.

Table 25-1. Graphics class overview

Purpose

Graphics method

Drawing lines

curveTo( ), lineTo( )

Drawing shapes

beginBitmapFill( ), beginFill( ), beginGradientFill( ), drawCircle( ), drawEllipse( ), drawRect( ), drawRoundRect( ), drawRoundRectComplex( ), endFill( )

Defining line styles

lineGradientStyle( ), lineStyle( )

Moving the drawing pen

moveTo( )

Removing graphics

clear( )

Conceptually, lines and curves are drawn in ActionScript by a theoretical “drawing pen.” For all new Sprite, MovieClip, and Shape objects, the pen starts out at position (0,0). As lines ...

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.
Start your free trial

You might also like

Essential ActionScript 2.0

Essential ActionScript 2.0

Colin Moock
The ActionScript 3.0 Quick Reference Guide

The ActionScript 3.0 Quick Reference Guide

Jen deHaan, David Stiller, Darren Richardson, Rich Shupe
ActionScript 3.0 Cookbook

ActionScript 3.0 Cookbook

Joey Lott, Darron Schall, Keith Peters

Publisher Resources

ISBN: 0596526946Errata