O'Reilly logo

ActionScript Graphing Cookbook by Peter Backx, Dominic Gélineau

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

Beyond the cube, drawing different shapes

Up until now, we have only drawn cubes. It's about time we looked at some other forms. In this recipe, we look at how you can use Away3D's built-in shapes to create different visualizations. We will replace the cubes from the previous recipe with cylinders.

Getting ready

We will adapt the previous recipe. So create a copy of it and move it to a new package or rename it. Finally, set it as the document class.

How to do it...

First let's make the Graph3D class a little more generic:

  1. Create a member variable inside the Graph3D class:
    public var drawFunction:Function = drawCube;
  2. Update the drawDataPoints method so it uses the new variable:
    private function drawDataPoints():void { for (var i:int = 0; i < _data.length; ...

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