Flash sample code for a weighing scale?

Posted on 2009-04-20
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

    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

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Using Quotation Marks in PHP This question ( seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
    Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
    The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: : Click on Too…
    The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now