Book Image

ActionScript Graphing Cookbook

Book Image

ActionScript Graphing Cookbook

Overview of this book

"A picture is worth a thousand words" has never been more true than when representing large sets of data. Bar charts, heat maps, cartograms, and many more have become important tools in applications and presentations to quickly give insight into complicated issues.The "ActionScript Graphing Cookbook" shows you how to add your own charts to any ActionScript program. The recipes give step-by-step instructions on how to process the input data, how to create various types of charts and how to make them interactive for even more user engagement.Starting with basic ActionScript knowledge, you will learn how to develop many different types of charts.First learn how to import your data, from Excel, web services and more. Next process the data and make it ready for graphical display. Pick one of the many graph options available as the book guides you through ActionScript's drawing functions. And when you're ready for it, branch out into 3D display.The recipes in the "ActionScript Graphing Cookbook" will gradually introduce you into the world of visualization.
Table of Contents (17 chapters)
ActionScript Graphing Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Animating the transitions


In the previous recipe, we allowed the user to navigate through but we didn't animate the transitions, so it looks unprofessional and clunky. Animations also help the users grasp what is happening. This recipe is going to show how to animate a relational network.

Getting ready

Open the files downloaded from the Packt Publishing website for Chapter 8 | Recipe 5 to follow along.

How to do it...

The following are the steps required to animate a relational network:

  1. In NodeVisual.as, remove the function addLink.

  2. Still in NodeVisual, add the function _updateLine:

    private function _updateLine():void {
      _link.graphics.clear();
      _link.graphics.lineStyle(3, _color, 0.8);
      _link.graphics.lineTo( -x, -y);
    }
  3. Add the animateIn function:

    public function animateIn():void {
      _targetX = x;
      x = 0;
      _targetY = y;
      y = 0;
      TweenLite.to(this, 0.5, {x:_targetX, y:_targetY, onUpdate:_updateLine, ease:Back.easeOut } );
    }
  4. Also add the public function animateOut:

    public function animateOut...