2 Replies Latest reply on Nov 18, 2008 9:56 AM by chemical_pete

    CS3 Risk Calculator (AS2)

    chemical_pete
      So I have been working on a calculator to help me calculate medical risks for patients. This will ultimately be a small part of a larger calculator, but I need to get this working first. I have an interface which has a drop-down for a Vessel Diameter. And there are also checkboxes to account for additional risks. What I want to do is have a "Total Risk" box dynamically reflect the changes from the drop-down and the clicking of the checkboxes.

      So far, I have assigned a boolean value to the checkboxes, as well as a data value. The drop-down box has values as well (including a multiplier). But with the event listeners applied to each, the text doesn't update dynamically, and if you uncheck a checkbox, the "Total" does not reflect that change. How can I write a string to add all of these Variables together?

      I finally got to a point where I could make sense and ask a somewhat intelligent question now. Still an actionscript noob, so be kind =). Any assistance would be greatly appreciated!!!!

      Thank you all!
      Pete~
        • 1. Re: CS3 Risk Calculator (AS2)
          Ned Murphy Adobe Community Professional & MVP
          From what you say it sounds like you need a function that adjusts a value based on selections made... such as...

          var endResult:Number = 0;

          function adjustValue(withThisNumber){
          endResult += withThisNumber;
          trace(endResult);
          }
          }

          so in each change handler, you would put

          adjustValue(withThisNumber);

          where withThisNumber is the data that you want to affect the result with (turtuosityADD, etc).
          • 2. Re: CS3 Risk Calculator (AS2)
            chemical_pete Level 1
            Ok, here's where the noob peeks out. I think I see where you are going with this. When I set up the Variable "endResult" and the Function "adjustValue" it looks like this:

            ...but when I check and uncheck the boxes, the result just continues to add rather than switch the value. What did I miss?