Graph Classes written in ActionScript 3

Whilst doing some work on an Mathematics Learning Object I was confronted with the problem of having to be a variety of different graphs.

Due to the way that these projects change over the construction period it soon became apparent that hand drawing these graphs would be too time consuming, so I set out to create some classes that could do most of the heavy lifting.

After a bit of planning and a lot of head scratching I finally came up with some classes that would do 95% of what I needed to do with the added bonus of being run from an external XML file structure.

The flash file below is an example of some of the things the classes could do.

Flash demo should be here

Without getting into the boring details it basically works like this:

  • One class handles the grid. It draws grid lines based on the area being viewed and the physical size of the graph.
  • A second class, the Graph class, manages all of the graph elements. It acts as a parent to them all, telling them when the graph dimensions or co-ordinates change etc.
  • A base class for all of the different ‘graph items’ acts as a common interface for all the different types of graphing elements you want to display. Each element knows how to render itself based on current graph settings.

That’s about it. There was lots of little nuances like conditionals controlling line visibility and figuring out what numbers should appear, etc. but nothing that was hard.

Download:

I’ve added a downloadable version of the demo shown above because a lot of people have been asking me for it. I would like to add though that this was written long time ago and I would do it all totally different now. Enjoy.

Graph Class Examples


{lang: 'en-GB'}
Posted in ActionScript | Tagged , , , | 10 Comments

10 Responses to Graph Classes written in ActionScript 3

  1. Arjun says:

    g8 job…….this is wonderful….can u mail me the source code of this flash file?

  2. Deive says:

    great job, I’m from Brazil, and mathematician, it can provide the classes for me to study very grateful.

  3. I’ve had a couple of requests for the source code now, and normally I would post it as a download, but I wrote it so long ago that it is really in a terrible shape and I think I would be ashamed to have it on my site.

    I do hope to one day fix all this up, but until then it will stay offline. If anyone really really wants it though, let me know and I will email it through.

  4. Aries says:

    It’s was great….I’m now learning flash as3…can u send me the source code?

  5. Rosemary Comella says:

    This is really great. Would you be willing to send me the source code?

  6. John Simon says:

    Nice job! I would truly appreciate if you would share the source code with me. I am new to actionscript/flash and thsi would be very helpful.

    Thanks!

  7. I’ve added a link to the source files for the demo above. It should have all the files you need.

  8. Matheus Castello says:

    How I can use the GraphLine functions?

  9. Eric says:

    Could I please have a copy of the AS3 work for the graphs. Do you have anything related to pie charts etc. :o) Thanks

  10. Hey Eric, there is a link to the files at the bottom of the post. It should have all the AS3 files I used in the demo. I wrote them a long time ago so I am going to guess that they are pretty ugly.
    I don’t have anything relating to Pie Charts.

Leave a Reply

Your email address will not be published. Required fields are marked *


7 − = three

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>