Developer Guide
container.y = stage.stageHeight / 2;
var satellite:Shape = new Shape();
addEventListener(Event.ENTER_FRAME, doEveryFrame);
function doEveryFrame(event:Event):void
currentDegrees += 4;
var radians:Number = getRadians(currentDegrees);
var posX:Number = Math.sin(radians) * radius;
var posY:Number = Math.cos(radians) * radius;;;, posY, satelliteRadius);
function getRadians(degrees:Number):Number
return degrees * Math.PI / 180;
To produce a significantly different result, you can experiment by modifying the initial seed variables at the
beginning of the code,
currentDegrees, radius, and satelliteRadius. For example, try shrinking the radius
variable and/or increasing the totalSatellites variable. This is only one example of how the drawing API can create a
visual display whose complexity conceals the simplicity of its creation.
Example: Algorithmic Visual Generator
The Algorithmic Visual Generator example dynamically draws to the stage several “satellites, or circles moving in a
circular orbit. Among the features explored are:
Using the drawing API to draw a basic shape with dynamic appearances
Connecting user interaction with the properties that are used in a draw
Conveying animation by clearing the stage on each frame and redrawing
The example in the previous subsection animated a solitary “satellite” using the
Event.ENTER_FRAME event. This
example expands upon this, building a control panel with series of sliders that immediately update the visual display
of several satellites. This example formalizes the code into external classes and wraps the satellite creation code into
a loop, storing a reference to each satellite in a
satellites array.
To get the application files for this sample, see The
application files can be found in the folder Samples/AlgorithmicVisualGenerator. This folder contains the following
File Description
AlgorithmicVisualGenerator.fla The main application file in Flash (FLA).
com/example/programmingas3/algorithmic/ The class that provides the main functionality of the
application, including drawing satellites on the stage
and responding to events from the control panel to
update the variables that affect the drawing of satel-

Get ADOBE® FLEX® 3: PROGRAMMING ACTIONSCRIPT™ 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.