A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: given a number so forumla to use

  1. #1
    Senior Member
    Join Date
    Nov 2001
    Posts
    137

    given a number so forumla to use

    Hi, I have 10 formulas, each converts a given number, depending of what that number is, depends on the formula to use on that given number.

    For example

    if the given number is 3.6 then I need to use a formula that is for numbers from 3 to 4.

    I have a scale of 0 to 10 with 10 formulas. I'm not sure how to go about action scripting this out.

    Lets say my given number is 3.6, I first need to find out that 3.6 is between 3 and 4, so I can use that formula, similarly is the number is 3.2, I use the formula that is used for number between 3 and 4. If the given number is 2.9 then I use the formula for numbers between 2 and 3.

    furthermore, I have this certain relationship where no formula is applied:

    given number that equal 0 have a set value of 0
    given number that equal 1 has set value of 8

    here is the set relationship (I don't think there is a pattern from number to number so I created a formula for number ranges, hence the need to determine what the given number range that it falls in)

    fixed: 0-8-15-22-48-60-73-87-100-114-128
    given:0-1-2- 3- 4- 5- 6- 7- 8- 9- 10

    for example of a formula I have:
    if the number given is 1.5 then I times this number by 8 to figure out where it would lie in the fixed number range.

    Like I said I have not found a pattern from 0 to 8 to 22 to 48.... so I broke each range between the number into their own formulas.

    //Hope if I lost you with my words I’m gaining you back by now

    so I need to determine what range the given number falls between into order to apply the formula to convert it to the fixed scale.

    How would one action Script such a monstrosity?

    Thanks

    (if someone can find a pattern so i need only use one formula cheers to that extremly keen individual )
    Last edited by havey; 09-22-2007 at 09:40 PM.

  2. #2
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    Floor a copy of the number and use a switch...case:

    Code:
    Math.floor (number) {
    
    switch (number) {
       case: 0
          //formula for 0-1
          break;
       case 1:
          //formula for 1-2
          break;
    ...
    }
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  3. #3
    Senior Member
    Join Date
    Nov 2001
    Posts
    137
    Thanks, i thought it would be too easy

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