Saturday, January 30, 2010

Flash Dial (Gauge) Component

For an application, I needed a Dial (Gauge) component made in flash (preferably in AS3), and open source!. After searching for sometime, I got some great, and some not-so-great components. A few are listed below:
  1. One of them, a classic, is from Bright Point, but unfortunately in flex.
  2. A good collection of components from AnyChart lie here, but not free.
  3. Another one was from XML/SWF, mediocre, but again paid.
Hence, decided to write my own. I am sure this could benefit few of you too.

Objective:
  1. Create a flash Dial component,
  2. that had capability to define regions (at least 3),
  3. as well as support percentage display,
  4. customizable background colors,
  5. real time value update without refresh would be bonus.

Here is the outcome written in flash (<30kb). It has the following methods:
  1. InitiliazeComponent: takes the following parameters: Minimum Value, Maximum Value, Percent Display Needed?, Region Definition
  2. DisplayNewValue: takes "New Value" as parameter. 
Rather than using the traditional SetVariable route, I used the ExternalInterface (which is by the way, newer and much better). Some very good posts are available in this regard, here. The ExternalInterface is also pretty smooth when calling from .NET applications. Will be covering this area later.

Here is the application being supported by a javascript test page. The loading of display parameters as well as dial value is done through javascript. The body onload event in the browser did not wait for the Flash SWF to load completely, firing much before the movie actually got loaded. Thanks to the new way of communication between flash and External apps, the parameter loading javascript waits for the flash to complete loading the movie first.

Do write in the comments if you like it and/or need the AS3 source code.

7 comments:

  1. Can I use this flash in an excel file

    ReplyDelete
  2. Can you send me the source code to dmaldonadop (at) gmail.com, please.

    ReplyDelete
  3. Dial Gauge is really good.. and better than the paid one.
    Can you send me the source code to venkisakthi@gmail.com

    ReplyDelete
  4. That's awesome gauge! Would you please send me the source code to ytw1990@gmail.com?

    Thank you so much!

    ReplyDelete
  5. this perfect suits to my requirement. Thanks a lot. Can you please mail the as3 source to sankarasapu@gmail.com

    ReplyDelete
  6. I too would like to use the code if you are willing to share it, this is really great. Would you please share it with me at hebgbe27@gmail.com, thank you.

    ReplyDelete
  7. please share this code at dysuknanda@gmail.com
    this code is perfact

    ReplyDelete