Flash sample code for a weighing scale?

Posted on 2009-04-20
Medium Priority
Last Modified: 2013-11-12
I'm looking for sample code or at least a rough idea of how to implement the following in Flash.  Basically I want to be able to tie numeric values to either sides of an animated balance, and be able to show a transition when the values in each side are shifted.

For example, say the total value fielded by the balance is 100, with 50 on the left and 50 on the right.  At equilibrium, there will be 50 on each side.  If the left is heavier, it might show 70 left, 30 right.  If the right is heavier, it might show 20 on the left, 80 on the right.  In either case the total adds up to 100.

I'd want to have the animation be fluid so that if a value on either side is changed, the transition can be seen once the user clicks a button or otherwise triggers an event to apply the change.  As far as the values themselves, I have no clue how Flash would grab such values outside of itself.  Could I have it look at the DOM and watch the values of a couple of textbox controls?  Could I tie it to a database and execute a scalar function when I need to grab the values?

If I don't need to use Flash and could instead do something like this from Javascript or some weird CSS tricks, that would be cool too, but I'm suggesting Flash at the outset because I have it handy and am just new at it.

Question by:Zoplax
1 Comment
LVL 39

Accepted Solution

blue-genie earned 1500 total points
ID: 24191457
you'd need to break up your graphic and move the registration point to the center of the bits that move.
then if you want to get the values from a db you need to use a server side script such as asp/php to retrieve those values and send them back to flash.
then based on the values you have you need to work out the degree of tilt and apply that as a rotation on your movieclip.

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question