a sort-of calculator with one function - read inside fro more detail
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: a sort-of calculator with one function - read inside fro more detail

  1. #1
    Junior Member
    Join Date
    Jan 2003
    Location
    Western Australia, South Perth
    Posts
    3

    a sort-of calculator with one function - read inside fro more detail

    Ok, I want to make a fla (using flash mx) that the viewer can enter a number into a thing then press a button and gives them the answer in another area.

    The formula is:

    a/16 = b
    int(b) = c
    (a/16-c)*16 = d

    c and d are looked up on the below table (left collumn) and are replace with the right collumn then renamed e and f

    | starts | ends |
    -----------------
    | 0` | 0 |
    | 1` | 1 |
    | 2` | 2 |
    | 3` | 3 |
    | 4` | 4 |
    | 5` | 5 |
    | 6` | 6 |
    | 7` | 7 |
    | 8` | 8 |
    | 9` | 9 |
    | 10 | A |
    | 11 | B |
    | 12 | C |
    | 13 | D |
    | 14 | E |
    | 15 | F |

    g = e&f

    a is the input
    g is the output

    To clarrify.

    a = 125
    125/16 = 7.8125
    int(7.8125) = 7
    (125/16-7)*16 = 13

    7 = 7
    13 = D
    g = 7&D

    input is 125
    output is 7D

    Can anyone help me create this calculator?
    Again, it is in fla format and created in Flash MX

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Location
    UK
    Posts
    493
    this code steps through each stage with functions.
    Place it on the maintimeline and call it as follows

    _root.Calculate(125)


    List=[0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F"]

    function Calculate(Input)
    {
    var result=""
    var temp=_root.Eq1(Input)
    temp=_root.Eq2(temp)

    var result=String(temp)

    temp=_root.Eq3(Input, temp)
    var result=result+String(temp)

    trace(result)
    }

    function Eq1(Num)
    {
    return Num/16
    }

    function Eq2(Num)
    {
    return Math.floor(Num)
    }

    function Eq3(Num,val)
    {
    var index=(Num/16-(Number(val)))*16


    return (_root.List[index])
    }

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

Poll by Flashkit.com