A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: calculation

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Posts
    23

    Question calculation

    Hello,

    I don't know very much about actionscript. Just enough to get by. I'm trying to put together a small application. I want the user to enter information, weight, and the application to tell the user which product to order. If the weight is within 1 of 4 ranges, he will use product #1, 2, 3, or 4. How can I get the product number to be entered in a seperate box if the weight falls within a certain range? I've figured out how to make calculations, but not conditions. Any help would be appreciated.
    thanks,

    Powersolo
    thanks a million!

  2. #2
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    Code:
    var x = /* user input */
    if (x < 10) {
       // bottom unbounded range x < 10
    } else if (x < 15) {
       // 10 <= x < 15
    } else if (x < 20) {
       // 15 <= x < 20
    } else {
       // top unbounded range x >= 20
    }
    If you want to test for the second range by itself, do so like this:
    Code:
    if (x >= 10 && x < 15) {
       // 10 <= x < 15
    }
    If you want to test for the second OR 4th range, do so like this:
    Code:
    if ((x >= 10 && x < 15) || x >= 20) {
       // 10 <= x < 15 or x >= 20
    }
    && is "and". || is "or". They are called short-circuit logic operators.
    http://help.adobe.com/en_US/FlashPla...operators.html
    http://en.wikipedia.org/wiki/Short-circuit_evaluation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center