dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Simple Calculation (anyone know how)

  1. #1
    Viresh1981
    Join Date
    Jul 2006
    Location
    BRADISTAN
    Posts
    40

    Simple Calculation (anyone know how)

    I have price * amount = total

    amount is an input box

    so the user can input any amount they require

    press a button and it will work out the total

    CalculatePrice = function (answer) {
    P = Price;
    A = Amount;
    the_total = P*A;
    return the_total;
    };
    submit.onRelease = function() {
    text_answer = CalculatePrice(the_total);
    };

    The above works

    got that work working but i need lots of these, now am a bit stuck here is the code that does not work:


    CalculatePrice = function (answer) {
    P = Price;
    A = Amount;
    P1 = Price1;
    A1 = Amount1;
    the_total = P*A;
    the_total1 = P1*A1;
    return the_total , the_total1;
    };
    submit.onRelease = function() {
    text_answer = CalculatePrice(the_total);
    text_answer1 = CalculatePrice(the_total1);
    };

    As you can see I have more than one total to work out, does anyone know how to do this? if so please let me know.

    I have also attached the .fla
    Attached Files Attached Files

  2. #2
    Viresh1981
    Join Date
    Jul 2006
    Location
    BRADISTAN
    Posts
    40

    Any One Needing A Count System Its Here

    I FIXED THE PROBLEM MYSELF - AND HERE IS THE SOLUTION

    Note you must publish the movuie to flash player 7 with actionscript 1.0 for it to work.


    The program:

    I have price * amount = total

    amount is an input box

    so the user can input any amount they require

    press a button and it will work out the total

    also there is another set underneath of an price*amount = total

    when the button is pressed it works out both calculations

    then adds the totals together to give a grand total with is displayed in a dynamic text box - any way here is the code - if anyone wants it:


    make a button then add this script to it:

    //
    on (release) {
    P = Number(Price);
    A = Number(Amount);
    Total = (P*A);
    T = Total;
    P1 = Number(Price1);
    A1 = Number(Amount1);
    Total1 = (P1*A1);
    T1 = Total1;
    GrandTotal = (T+T1);
    }
    //


    make sure your text boxes match the code in the scipt or it won't box

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