Calculator with two numbers

Dear Forum
Im working a calculator with a textfield. It can calculate a if a enter only one number, but when i try to enter two or three doesnt work. I have test several codes but they are not working at all. Could any someone give me a hand. Please se te attach file.
var numeroEntrado = "";
var campoUno:int = 125;
var campoDos:int = 20;
var elResultado1 = 0;
var elResultado2 = 0;
proteinas.text = "125 grs.";
colesterol.text = "20 mml.";
colesterol.backgroundColor = 0x9999FF;
textoColesterol.backgroundColor = 0x9999FF;
numeroPorciones.maxChars = 3;
numeroPorciones.restrict = "0-9";
btn.addEventListener(MouseEvent.MOUSE_UP, suma);
function sienteTecla(event:KeyboardEvent):void {
    if (event.keyCode == 48) { numeroEntrado = 0; }
    if (event.keyCode == 49) { numeroEntrado = 1; }
    if (event.keyCode == 50) { numeroEntrado = 2; }
    if (event.keyCode == 51) { numeroEntrado = 3; }   
function suma(evt:MouseEvent):void{
        proteinas.text = "";
        elResultado1 = Number(campoUno) * Number(numeroEntrado);
        proteinas.text = elResultado1 + " grs"; 
        colesterol.text = "";
        elResultado2 = Number(campoDos) * Number(numeroEntrado);
        colesterol.text = elResultado2 + " mml" ;
        numeroPorciones.text = ""
thanks
IN

It's difficult to say without understanding your intent.
I don't see where you event listener for sienteTecla  is being assigned.
If numeroEntrado is supposed to be numeroPorciones value (a guess) then perhaps you could just do something like this:
function suma(evt:MouseEvent):void{
    if (numeroPorciones.text!="") {
        proteinas.text = "";
        elResultado1 = Number(campoUno) * Number(numeroPorciones.text);
        proteinas.text = elResultado1 + " grs";
        colesterol.text = "";
        elResultado2 = Number(campoDos) * Number(numeroPorciones.text);
        colesterol.text = elResultado2 + " mml" ;
        numeroPorciones.text = ""

Similar Messages

  • Calculations with Rounded Numbers

    I've created a form in Adobe X that has a few calculated fields.  For ease of conversation, we'll call them Field A, Field B and Field C (see below).  I need Fields A and B to be rounded to the nearest whole number so that Field C is also a whole number.  I've tried formatting Fields A and B to show no decimals but the calculaton is still being performed on the non-rounded numbers.  Can anyone help with this?  Thanks.
    Field A - Field B = Field C

    George I must be missing something.  I added the math.round functions as shown in your example but now it doesn't calculate at all.  Can you look at the coding shown below and let me know where I went wrong?  Thanks.
    Updated Coding:
    (function(){
    var totalMiles = math.round(+this.getField("Total Miles DrivenRow1").value);
    var homeMiles = math.round(+this.getField("Home Base MilesRow1").value);
    var diff = totalMiles - homeMiles;
    if (diff<0) diff = 0;
    event.value = diff;})();
    Original Coding:
    var totalMiles = +this.getField("Total Miles DrivenRow1").value;
    var homeMiles = +this.getField("Home Base MilesRow1").value;
    var diff = totalMiles - homeMiles;
    if (diff<0) diff = 0;
    event.value = diff;

  • Calculations with floating numbers

    I am doing some calculations within an application have have found the following happens:
    System.out.println("calculation: " + (22.0*4.4));
    results in the output:
    calculation: 96.80000000000001
    Why is this? I understand that rounding has to happen on sum figures, but not these two - how can I get the 'proper' result of 96.8??
    Thanks

    import java.math.BigDecimal;
    public class Test {
        public static void main(String[] args) {
            double d1 = 22.0;
            double d2 = 4.4;
            System.out.println(d1);
            System.out.println(d2);
            // with Java 5.0 printf
            System.out.printf("%.1f%n", d1 * d2);
            // With BigDecimal
            BigDecimal bd1 = new BigDecimal(d1);
            BigDecimal bd2 = new BigDecimal(d2);
            System.out.println(bd1);
            System.out.println(bd2);
            BigDecimal product = bd1.multiply(bd2);
            BigDecimal scaled = product.setScale(1, BigDecimal.ROUND_HALF_UP);
            System.out.println(scaled);
    }Cheers, Neil

  • 2 BBs with two numbers and same email address

    Hello,
    I have a BB with a Vodafone number from Portugal. I want to buy now
    another BB to use with another Vodafone number, this case from
    Ireland.
    My question is whether I can have both phones working with the same
    gmail address at the same time? When an email is received it will go
    to both phones at the same time?
    thanks for your help
    Manuel
    Solved!
    Go to Solution.

    Jameskemp is correct.
    When you set up an email address on your BlackBerry, you're associating the delivery of that email address to your phone's PIN.  You can't have one email address going to two different PINs simultaneously.
    Now you know. 
    - If my response has helped you, please click "Options" beside my post and mark it as solved. Clicking the "thumbs up" icon near the bottom of my response would also be appreciated.

  • Dealing with two numbers at one contact is a problem

    I managed to backup and transfer anything I want from my iphone 4 to my PC without syncing or using internet connection. All by usb cable. But the one thing that I can not manage any more is my CONTACTS. Iws trying to compy my contacts to other Nokia phone. I use 2 or more numbers for one contact. For example
    First Name: Sean
    Mobile: 011111111111
    Mobile: 02222222222
    Other: 03333333333
    I synced with Windows Contacts and Outlook but always the data (contacts) on my PC shows one Mobile and Other so in my example it will show like this
    First Name: Sean
    Mobile: 011111111111
    Other: 03333333333
    So is there any way to backup/sync my all contacts with full info even custom labels ?
    This is my first question so excuse me if I did anything wrong by posting it

    innesco wrote:
    This is partial solution thank you Michael Black but it didn't work when I used more than one Custom Label for example
    First Name: Sean
    Mobile: 011111111111
    CustomLabel1: 02222222222
    CustomLabel2: 03333333333
    and the result in outlook is
    First Name: Sean
    Mobile: 011111111111
    Other: 03333333333
    Any ideas ?
    In my Outlook 2007, the phone number fields are specifically defined in the predefined dropdown list.  I see no option to use anything but those in that dropdown list, so I'd say you must make sure that each phone number field you set up on your iPhone contacts matchs, exactly, one of those in the Outlook allowed field names.  Being a typical MS program, you must rigidly use their assigned field names

  • 2 iPhones connected to one iTunes account? With two numbers- is it possible

    I have an iPhone And we are planning on getting another one. My husband is going to take mine and we'd like to switch it to his number and I will get the 3g. We want to synch both to my iTunes acct. To share the music etc. Can we do this? How? How do we switch my phone to his number?

    Yes, it's possible. iTunes will recognize each as a separate device and you can select what you want synced on each. This article (http://support.apple.com/kb/HT1386) does mention that you cannot connect both at the same time.
    AT&T has a nice video about giving your old phone to someone else and getting it activated. You would have to get a new sim card for the phone you are giving to your husband. See the video here" http://www.att.com/gen/press-room?pid=6158&cat=32&u=619. It would probably be best to go to your local AT&T store and talk about changing his phone number and getting a family phone account.
    Since you will both be using your iTunes Store account, you should have no problems sharing music and apps.

  • I have one itunes account with two phones. when i phone one of the numbers both phones have started to ring, only when connected to wifi at home. How do i resolve this please?

    I have one itunes account with two phones assigned to it, sons and daughters, (5s). When i phone one of the numbers both phones have started to ring, only when connected to wifi at home. The problem does not occur when not connected to wifi. How do i resolve this please? texting is fine it is only when ringing one of the numbers.

    <http://support.apple.com/kb/HT6337>
    "To turn off iPhone Cellular Calls on a device, go to Settings > FaceTime and turn off iPhone Cellular Calls."

  • I bought a new iphone and as i was setting my apple ID account and i signed in to my account and confirmed two useres with diffrent numbers that were signed to the same apple ID and it messed up my i messege and face time. how do i fix that ?

    i bought a new iphone and as i was setting my apple ID account and i signed in to my account and confirmed two useres with diffrent numbers that were signed to the same apple ID and it messed up my i messege and face time. how do i fix that or delete one user ?

    Hello sapiii96,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    iOS: Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/ts4268
    To sign out of your Apple ID
    Go to Settings > FaceTime, tap your Apple ID, and select Sign Out.
    Go to Settings > Messages > Send & Receive, tap your Apple ID, and select Sign Out.
    Best of luck,
    Mario

  • I have two different 5s's with two different phone numbers but they are both using the same iCloud/apple account. After upgrading to iOS8 when I get a phone call on one phone both phones ring.

    I have two different 5s's with two different phone numbers but they are both using the same iCloud/apple account. After upgrading to iOS8 when I get a phone call on one phone both phones ring. One phone is for work and one is for private and I don't need both phones to ring from one call. It's bizarre.......is this supposed to be like this? If so where can I turn it off?? And while we are at it iOS8 has installed iBooks on both of my phones and iTunes won't let me uninstall it. I don't need or want iBooks on my phones.

    Hi,
    There are two easy fixes to this.
    One, you can set up Family Sharing, in which you can have two different iCloud Accounts, yet still share the same apps, music, media etc.
    Two, go to Settings and turn-off "Handoff". This can be found under the General page.
    Hope this helps!

  • Is it possible to use a single iPhone with two contact numbers via dual sim or an app?

    Is it possible to use a single iPhone with two contact numbers via dual sim or an app?
    This would be a useful feature for personal and company numbers but using one mobile, rather than carrying two devices or diverting calls.

    Then go ahead and try it.  You'll find it's probably a load of crap.
    You want 2 numbers, then use Google Voice or TalkaTone
    Those are US based only Apps or numbers so no good. I won't be wasting money by just trying something either, especially because using a dual sim would mean purchasing another sim card on either pay as you go or monthly contact.

  • HT4528 Can I put the same information on two different i-phones with different numbers and different ID's?

    Can I put the same information on two different i-phones with different numbers and different ID's?

    Yes and no it really depends on what information you are putting on the devices.

  • Calculation of interest amount with two variables formula

    Hello everyone,
    Iu2019m facing a problem with the way that TRM calculate the interest amount for money market transaction when I have a formula with two variable, e.g. reference interest rate u201CXu201D multiplied by 0,98.
    Some contracts explicitly say that to obtain the u201Cdaily interest rateu201D of the contract firstly the u201Cdaily interest rateu201D of the reference interest rate must be calculated and then apply a index or factor (e.g. 0,98). In the other hand some contracts says that it should be done the other way around. Iu2019ve noticed that TRM calculate the interest amount using the first way.
    Is there any way to set which the way the interest amount should be calculates?
    Has anyone faced similar problem?
    The examples below illustrate the difference in the two ways to calculate interest amount.
    Considering the following money market transaction:
    1. Borrowing structure:
    1.1. amount: USD 1.000.000,00
    1.2. flow type: 1105 u201CBorrowing/Increaseu201D
    2. Term (only one day to simplify the example)
    2.1. Start date: 30.01.2011
    2.2. End data:   31.01.2011
    3. Interest structure:
    3.1. Interest form: VARIABLE ( formula = Z1 * 0,98), where u201CZ1u201D is a reference interest rate
    3.2. condition type: 1200 u201CNominal interestu201D
    3.3. Interest calculation method: ActW/252
    Considering that Z1u2019s annual interest rate in 30.01.2011 is 11,66%, TRM would perform the following calculation:
    1. Contract annual interest rate (%) = Z1*0,98 = 11,66 *0,98 = 11,42680000%
    2. Convert from u201CContract annual interest rate (%)u201D  to number = 1,11426800
    3. u201CContract daily interest rateu201D = 1,11426800 ^(1/252) = 1,00042945
    4. Convert from u201Cnumberu201D to Day interest rate (%)  = 0,04294481%
    5. Interest amount = u201CContract daily interest rateu201D * Borrowed amount = 0,04294481% * 10.000.000,00 = 4.294,48
    In the other hand, some contracts say that the interest rate should be calculated in the following way:
    1. Annual interest rate (%) = 11,66  = 11,66000000%
    2. Convert from u201CAnnual interest rate (%)u201D  to number = 1,11660000
    3. Daily interest rate = 1,11660000 ^(1/252) = 1,00043775
    4. Convert from u201Cnumberu201D to Daily interest rate (%)  = 0,04377480%
    5. Calculate u201CContract daily interest rateu201D = 0,04377480% * 0,98 = 0,04289930%
    5. Interest amount = u201CContract daily interest rate (%)u201D  * Borrowed amount = 0,04289930% * 10.000.000,00 = 4.289,93
    With this simple scenario  we end up with a USD 4,55 difference for a single day, but for big contracts of hundred millions and for several years the difference is quite  huge.
    Thanks in advance ..
    Giuliano

    Hi,
    with Product Category 550 you can have both scenarios:
    for the 1st case you can use a formular (e.g. EONIA * 0,98)
    => interest for 1 day: 462,70 EUR
    for the 2nd case you can use the field Variable Interest Rate (EONIA) + field Payment Rate (98)
    => interest for 1 day: 453,44 EUR
    Is this, what you are looking for?
    Regards,
    Lorenz

  • Working with two or more tables in Numbers

    Working with two or more tables in Numbers
    It is possible to write numbers or names in Table 1 B-2, B-3, B-4, B-5, B-6 etc. and automatically copy in Table 2 only B-2, B-4, B-9, B23 etc.
    What do I need to do???
    Thanks for the help

    The table on the left is named "Source" and on the right "Destination":
    In the table "Destination" on the right:
    B2=Source :: B2
    select B2 and fill down

  • Using imessage with two mobile numbers  on one iphone?

    hi is it possible to use two mobile numbers on imessage ,   with only one iphone?
    i have an old phone , and an iphone, but would like to be able to use receive imessages on the iphone  , using the two numbers,  is this possible?
    thanks

    no

  • GTS BP with two adress numbers.

    Hi All,
    I am facing with an issue that a BP is assinged with two address numbers. Ideally it should be one with our case .
    It was tranfered from ECC and for a ECC customer master only one adreess number can be exist.
    The 2nd adress was changed from ECC but unfortunatly instead of updating the existing one , it created one more adress line in GTS .
    When I checked in BUT020 table for this BP two adresses are assigned and no external adress for either of both add. numbers.
    I tried with other sample customer masters but neither able to re-create nor the cause of the issue.
    Kindly help by suggesting any check points , settings..Let me know if any other information is needed.
    Thanks ,
    Raj KB .

    Hi Raj,
    I have seen a similar issue before but on a larger scale.
    The previous incident was caused by a number range overflow that was not solved in the correct manner.
    Instead of correcting the problem in GTS first, the master data was re-transferred again from ECC in an attempt to overwrite the incorrect data.
    But because the number range was not corrected in GTS first the re-transfer created a lot of inconsistent entries in the BUT020 and ADRC tables.
    The attempted solution caused an incorrect relationship between ADRC and BUT020 for the (over 350k) BPs involved.
    This may not be the case in your scenario but it's the only root cause I can think of without having access to you system.
    Please inquire about the number ranges if the above sounds familiar.
    Going forward you should run program /SAPSLL/BP_ADDR_CLEANUP from SE38 in simulation mode to see what gets picked up.
    Best Regards,
    Eoin

Maybe you are looking for