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

Loading a file from the local hard drive


In the previous recipe, we've already seen one way of loading a file from the hard drive through relative URLs. There are a few shortcomings to that approach though, as follows:

  • If the Flash application is on a website, you cannot use the URLLoader class to load a file from the user's hard drive

  • Even if this was possible, we'd need to implement something so that the user can choose which file to load

In this recipe, we will demonstrate how to use a file dialog to let the user select which file to show.

Getting ready

Again, copy and paste the previous recipe's code into a new class called Recipe3. Rename the class name and the constructor and remove the three lines that create and start the URL loader. Leave the onComplete method as we will re-use it in this recipe.

package  
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.HTTPStatusEvent;
    import flash.events.MouseEvent;
    import flash.net.FileFilter;
   ...