Just adding 2 numbers.

Adding 2 numbers having 3 textfields and a button, I can do. The first textfield for input one, the second one for input two and the third one for output (result). The button triggering the operation.
recently, some of you helped me with the calculus of the square root. As you can see below:
http://www.er.uqam.ca/nobel/m340201/test/newestcalc.html
My question now, how can I add 2 numbers only with one textfield( result) and 4 buttons. One button for number 1, another one for number 2, another one for the operator +, and finally another one for the sign =.
I have the code, and being new at this I cannot figure out how to put everything to work:
import flash.events.Event;
var txt_inp:TextField = new TextField();
txt_inp.type = "input";
txt_inp.x = 168.95;
txt_inp.y = 51.10;
txt_inp.width = 209;
txt_inp.height = 52.90;
txt_inp.border = true;
txt_inp.borderColor = 0x0000da;
txt_inp.restrict = "0-9.";
var myFormat:TextFormat = new TextFormat();
myFormat.size = 44;//myFormat.align = TextFormatAlign.CENTER;
myFormat.align = TextFormatAlign.JUSTIFY;
txt_inp.defaultTextFormat = myFormat;
txt_inp.textColor = 0x0000FF;
txt_inp.maxChars = 5;
txt_inp.multiline = false;
txt_inp.text = '';
addChild(txt_inp);
var num1:Number;
var num2:Number;
button1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
button2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(e:MouseEvent):void
txt_inp.appendText(e.currentTarget.name.substr(6));
buttonplus.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_5);
function fl_MouseClickHandler_5(event:MouseEvent):void
trace("Mouse clicked");
equale.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_6);
function fl_MouseClickHandler_6(event:MouseEvent):void
trace("Mouse clicked");

Hi
THe code gives me the following:
When I input the number 1, it appears in the textfield, and then I click on +, and then I input number 2  which also appears in the textfield, and when I press on =, I get the result 3. It is a bit confusing because instead of having just the result (3), I get all the numbers in the textfield. which is 123. I should be having only the last number(3).
I tried to sovlve it alone first, but it is a bit too tricky and it took all the day.
NB: May be the code you gave me is the blessing, and all I have to do is add between 1 and 2 the sign +(plus), and between 2 and 3, the sign = (equal). And then it would look like the real thing.
But I don't know how to code them. Is it 187 ?
import flash.events.Event;
var txt_inp:TextField = new TextField();
txt_inp.type = "input";
txt_inp.x = 168.95;
txt_inp.y = 51.10;
txt_inp.width = 209;
txt_inp.height = 52.90;
txt_inp.border = true;
txt_inp.borderColor = 0x0000da;
txt_inp.restrict = "0-9.";
var myFormat:TextFormat = new TextFormat();
myFormat.size = 44;//myFormat.align = TextFormatAlign.CENTER;
myFormat.align = TextFormatAlign.JUSTIFY;
txt_inp.defaultTextFormat = myFormat;
txt_inp.textColor = 0x0000FF;
txt_inp.maxChars = 5;
txt_inp.multiline = false;
txt_inp.text = '';
addChild(txt_inp);
button1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
button2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(e:MouseEvent):void
txt_inp.appendText(e.currentTarget.name.substr(6));
var num:Number=0;
buttonplus.addEventListener(MouseEvent.CLICK, plusF);
function plusF(event:MouseEvent):void
if(!isNaN(Number(txt_inp.text))){
num = Number(txt_inp.text);
} else {
equale.addEventListener(MouseEvent.CLICK, equalF);
function equalF(event:MouseEvent):void
if(!isNaN(Number(txt_inp.text))){
txt_inp.text=String(num+Number(txt_inp.text));
} else {
txt_inp.text=String(num);
num=Number(txt_inp.text);

Similar Messages

  • ADDING WEEK NUMBERS IN THE CALENDAR OF IPHONE

    Hi,
    haven't found option of adding week numbers on my iphone 3gs calendar. in working life week numbers are pretty important and would need the option on daily basis. i syncronise my calendar from office outlook / exchange. office supports the feature, but week numbers dont follow.
    any ideas anyone?!

    I use Google calendar and sync it to my iPhone calendar over the air via Google Sync. There are a number of "gadgets" or sub-calendars you can add to your Google calendar (i.e. Moon phases, contacts birthdays, etc.) that will sync over to iPhone. I searched for week numbers and sure enough there is a "gadget" that will add this functionality with an option of weeks starting on Sundays or Mondays. Though I've never used them, I now have week numbers on my iPhone calendar.
    You would have to set up a free gmail account to create a google calendar but you wouldn't need to use it (mail or calendar) except to sync week numbers if you don't want to. If you want to go through the (relatively) small amount of trouble to do this just start a gmail account and then follow these instructions: http://www.google.com/support/mobile/bin/answer.py?answer=138740&topic=14252
    Except of course you will only turn on calendar. Then (on your MAC) go to your gmail and click on 'calendar' in the upper left. From there click on 'settings' in the upper right, then on the 'labs' tab. Enable the option to 'Add any gadget by URL.' Save this setting then go back to the calender itself and on the right where it says 'Gadget URL' paste http://sites.google.com/site/gcalweeknumbers/Home/calendar-gadget.xml
    Then, on your phone's web browser go to http://m.google.com/sync and sign in with your gmail info. Bookmark this page. Select your device and check the boxes for 'My Calendars' and 'Week Numbers'. Now when you open the calendar app on iPhone tap 'calendars' on the upper left and you should see (yourname)@gmail.com (Exchange) with 'Week Numbers' listed below it. Make sure you are viewing 'All Calendars' within the app and week numbers will show up on the Sunday or Monday of each week.
    I apologize if these directions are not clear enough or too wordy. I tried to describe it for someone without much experience with this stuff (meaning myself). It may seem like a lot of trouble, but if you really want week numbers you can do it!

  • Fixing acrobat pro XI crash when adding bates numbers

    Upgraded from Pro 8 to Pro 11 and regretting it.  Now the program just won't work.  Process of adding bates numbers is simple.  Once I finally find where the "tool" is hidden, I add a document and then select add bates number.  There is "OK" button, but when I click that, program crashes.  Every time, every document regardless of size.

    I just tried works for me.

  • I just added money to my account and i haven't bought apps in a long time and i forgot the answers to the security questions.

    I just added money to my account and i haven't bought apps in a long time and i forgot the answers to the security questions. How do i reset them?

    Alternatives for Help Resetting Security Questions and/or Rescue Mail
         1. If you have a valid rescue email address, then use this procedure:
             Rescue email address and how to reset Apple ID security questions.
         2. Fill out and submit this form. Select the topic, Account Security. You must
             have a Rescue Email to use this option.
         3. This is the only option if you do not already have a valid Rescue Email.
             These are telephone numbers for contacting Apple Support in your country.
             Apple ID- Contacting Apple for help with Apple ID account security. Select
             the appropriate country and call. Ask to speak to the Account Security Team.
         4. Account security issues almost always require you to speak directly to an
             Apple representative to securely establish your identity as the account holder.
             You can set it up so that Apple calls you, either immediately or at a time
             convenient to you.
                1. Go to www.apple.com/support.
                2. Choose Contact Support and click Contact Us.
                3. Choose Other Apple ID Topics and choose the appropriate topic for
                    your issue.
                4. Follow the onscreen instructions.
             Note: If you have already forgotten your security questions, then you cannot
             set up a rescue email address in order to reset them. You must set up
             the rescue email address beforehand.
    Your Apple ID: Manage My Apple ID.
                            Apple ID- All about Apple ID security questions.

  • Hi Guys,  I am using the full width video widget on a site. The widget was working perfectly however I have just added additional content to the site and re-uploaded and now the video is not working! Please help I have tried everything and am freaking out

    Hi Guys,
    I am using the full width video widget on a site. The widget was working perfectly however I have just added additional content to the site and re-uploaded and now the video is not working! Please help I have tried everything and am freaking out as this web-site has been payed for by my client.
    Alex

    Many thanks.
    With those symptoms, I'd try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

  • In ical I just added new calendars to a pre-existing calendar group, I can make events with these calendars, but not reminders, any suggestions?

    in ical I just added new calendars to a pre-existing calendar group, I can make events with these calendars, but not reminders, any suggestions?

    Hi,
    Lion has changed the way reminders (todos as was) work. They now seem to need to be in a seperate calendar.
    In iCal open the File menu and select New Reminder List... and select where to put it.
    Best wishes
    John M

  • We just added a new printer and bluetooth connection to our iMac.  Now iTunes does not recognize our iPads as devices.  Have already tried restarting everything.  Any other suggestions?

    We just added a new printer and bluetooth connection to our iMac.  Now iTunes does not recognize our iPads as devices.  Have already tried restarting everything.  Any other suggestions?

    You can try the steps recommended here: http://www.apple.com/support/ipad/assistant/itunes/

  • I have a macbook 4.1 with osx10.6.8 and just added memory (2gig) so I could sync my new Ipome and Ipad.  and Ipad. Now I'm told I need to upgrade my operating system. The apple store gave me conflicting instructions. Any suggestions? Thanks

    I have a macbook 4.1 with osx10.6.8 and just added memory (2gig) so I could sync my new IPhone and Ipad. Now I'm told at the apple store that I need to upgrade my operationg system. They said they couldn't help and gave me conflicting advice about what to do. Any ideas? Thanks you!

    There are three models of MacBook that comprise the 'macbook 4.1' category, and each of them a little different; however other than 'macbook 4.1' the other thing they have in common is they all are considered Early 2008. Two are white, one black, polycarbonate case, Core2Duo 2.1GHz, 2.4GHz white, 2.4GHz black.
    So if you can determine which one, if any of these, is the model build year and spec you have, that would be handy. Did you tell whoever you spoke to the serial number of your computer, so they'd know by looking up the specs to see what the supported maximum RAM upgrade capacity was, and other minimum requirements to make any upgrade to Mac OS X 10.6.8 at all?
    If you have the serial number you can do a lookup to 'indentify by serial number' online, and use that information to determine if the computer needs even more RAM to take it past the minimum for Snow Leopard 10.6.8 and then get it ready to upgrade (via paid download from App Store, Snow Leopard gets you that far) and see what the next supported OS X full upgrade would be for the hardware limitations on that old MacBook.
    If your MacBook IS a 4.1 build, the highest OS X it could run if it has the 2.4GHz cpu, is Lion 10.7.5. That would be an upgrade from the App store, available to OS X 10.6.8+ computers that access it online. And I kind of doubt how supported a newest iphone etc may be in lion.
    everymac.com has a fair amount of information across many years of Apple computing hardware...
    Here's the three MacBooks that share the 4.1 designation; first shipped with as much as 1GB RAM upgrade and the other two only a 2GB RAM*, (one white/one black color) according to this information...
    • MacBook "Core 2 Duo" 2.1 13" (White-08) 2.1 GHz Core 2 Duo (T8100)   
    • MacBook "Core 2 Duo" 2.4 13" (White-08) 2.4 GHz Core 2 Duo (T8300)  
    • MacBook "Core 2 Duo" 2.4 13" (Black-08) 2.4 GHz Core 2 Duo (T8300)
    ...as seen here: http://www.everymac.com/systems/apple/macbook/index-macbook.html
    *But according to MacTracker (free: download database) http://mactracker.ca
    these MacBooks can use more RAM in aftermarket specs as much as:
    Maximum Memory
    6.0 GB (Actual) 4.0 GB (Apple)
    Memory Slots
    2 - 200-pin PC2-5300 (667MHz) DDR2 SO-DIMM
    To get more information use a service such as this...
    •identify by serial number:
    http://www.powerbookmedic.com/identify-mac-serial.php
    The Apple? store or whoever you talked, to may have been as accurate as they could be without further research. Could be you may have a newer or older MacBook, which would change whatever later OS X it could run past 10.6.8. And to go past Snow Leopard, you need to download the last bits for 10.6.x to be able to go and get any later upgrade. The ones that may let a newest iphone or ipad work with it, are past SL10.6.8
    Anyway, as you further verify the model build year and configuration specifications, report back.
    Good luck & happy computing!

  • I have a MacBook Pro and just added an airport express to listen to my iTunes on my stereo. How do I get Firefox to use my AX when I use Grooveshark or Pandora?

    i have a MacBook Pro and just added an airport express to listen to my iTunes on my stereo. How do I get Firefox to use my AX when I use Grooveshark or Pandora?

    If the purchases are all from the same account then you can share the content by authorizing each device.
    If you have separate accounts then you have to be authorized to use the content purchased from another account.
    MJ

  • I'm trying to get organized and I just added a bunch of books and pdfs to my itunes library. They were all added immediately to my ipad and iphone even though, itunes automatically putting books on my idevices

    I'm trying to get organized and I just added a bunch of books and pdfs to my itunes library. They were all added immediately to my ipad and iphone even though I did not want this. I added them to itunes using add to library and I have both devices set to sync only selected books.
    How do I do this in the future so this doesnt happen? Its a lot of work to now manually erase them from each device and it sent my phone over capacity.
    thanks

    I dont see the difference in the posts. I dont think theres anything inaccurate or misleading about what I wrote. The items were immediately added to my ipad and my iphone, even though I have them both set to sync only select items. As soon as I added new titles to my itunes library, they were immediately added to the devices. Not on the next sync. Immediately. Both devices were plugged into the computer at the time. Sorry if I failed to mention they were plugged in but I dont see the signifigance youre making out of it. The problem persists anyway.
    Now that I did a test without the devices plugged in, the new items were still added as soon as I plugged my devices into the computer ( I do not have them set to sync over wifi).
    Since I have both devices set to manually select items to sync, of course I want to manually select new items to sync. For instance, I am not going to read any of these magazines or books on my phone, ever, and I dont want to waste valuable space with them.
    So I'm trying your advice:
    I just tried deselecting sync books. It erased all content from ibooks on my device. I then dragged
    one title onto the device, and it just goes back to syncing select books, with the one title selected.
    It appears that wont work to solve my issue. The next time I add something to itunes it will be put on my phone. Is this really something most people want? To select to manualy control what content is synced, but then have things automatically added. It seems inconsistent to me.

  • I have a running set of data in my Notes. I just added to 1 of my notes. When finished by mistake I clicked   and not Done. So I clicked Done on the blank page. This brought me to Notes menu and the 1 I was working in is gone. I never hit delete.

    I Have a running set of topics in my Notes. I just added to Note topic on iPhone 5. When I finished I mistakenly clicked + instead of Done. When I saw the blank page that appeared after the + click, I clicked Done. That brought me back to the menu of my notes - and the note topic I was working on was not there. Disappeared. At NO time did I click Delete. I have looked thru all my other note categories to see if some how the disappeared note was added to an existing note but it is not. After 3 or 4 minutes of looking around my iPhone notes, I checked my iPad Notes and the topic was missing from there also.
    Any ideas where this Note topic went or how to recover? Or am I SOL???
    THank you

    After a week's worth of debugging, I found the issue.
    The Java type returned from the call was defined as ArrayList.  Changing it to List resolved the problem.
    I'm not sure why ArrayList isn't a valid return type, I've been looking at the Adobe docs, and still can't see why this isn't valid.  And, why it works in Debug mode and not in Release build is even stranger.  Maybe someone can shed some light on the logic here to me.

  • I have a production mobile Flex app that uses RemoteObject calls for all data access, and it's working well, except for a new remote call I just added that only fails when running with a release build.  The same call works fine when running on the device

    I have a production mobile Flex app that uses RemoteObject calls for all data access, and it's working well, except for a new remote call I just added that only fails when running with a release build. The same call works fine when running on the device (iPhone) using debug build. When running with a release build, the result handler is never called (nor is the fault handler called). Viewing the BlazeDS logs in debug mode, the call is received and send back with data. I've narrowed it down to what seems to be a data size issue.
    I have targeted one specific data call that returns in the String value a string length of 44kb, which fails in the release build (result or fault handler never called), but the result handler is called as expected in debug build. When I do not populate the String value (in server side Java code) on the object (just set it empty string), the result handler is then called, and the object is returned (release build).
    The custom object being returned in the call is a very a simple object, with getters/setters for simple types boolean, int, String, and one org.23c.dom.Document type. This same object type is used on other other RemoteObject calls (different data) and works fine (release and debug builds). I originally was returning as a Document, but, just to make sure this wasn't the problem, changed the value to be returned to a String, just to rule out XML/Dom issues in serialization.
    I don't understand 1) why the release build vs. debug build behavior is different for a RemoteObject call, 2) why the calls work in debug build when sending over a somewhat large (but, not unreasonable) amount of data in a String object, but not in release build.
    I have't tried to find out exactly where the failure point in size is, but, not sure that's even relevant, since 44kb isn't an unreasonable size to expect.
    By turning on the Debug mode in BlazeDS, I can see the object and it's attributes being serialized and everything looks good there. The calls are received and processed appropriately in BlazeDS for both debug and release build testing.
    Anyone have an idea on other things to try to debug/resolve this?
    Platform testing is BlazeDS 4, Flashbuilder 4.7, Websphere 8 server, iPhone (iOS 7.1.2). Tried using multiple Flex SDK's 4.12 to the latest 4.13, with no change in behavior.
    Thanks!

    After a week's worth of debugging, I found the issue.
    The Java type returned from the call was defined as ArrayList.  Changing it to List resolved the problem.
    I'm not sure why ArrayList isn't a valid return type, I've been looking at the Adobe docs, and still can't see why this isn't valid.  And, why it works in Debug mode and not in Release build is even stranger.  Maybe someone can shed some light on the logic here to me.

  • I just added LG GP 60 Dvd writer to my mac and it will not open when I press the button to release the dv

    I just added an LG GP60 DVD writer to my Macbook Pro and the the drive will not release the disk when I try to ejecct it...any one can help?

    I only got a disc for windows and I have read that for mac it is a plug and play. It works fine when I put the disc in but when I go to remove it I have to unplug it from the USB connection and replug and then the light comes on and I can hit the release button.  I want to be able to hit the release button and the drive door just pops out so I can remove my CD.

  • I just added my Facebook contacts with my iphone Contacts, how can I include those in my mac Contacts?

    I just added my Facebook contacts with my iphone Contacts, how can I include those in my mac Contacts?

    I did that, but the recently added FB contacts in my iphone are not on my mac's contacts.

  • Where is the Just added link in iTunes 10.7

    Updated to iTunes 10.7, where is the Just Added link hiddden, It was there last week.

    The "recent releases" is all that seems to be available now. Whether the old "just added" section will ever reappear, no one here can say. You can express your desire for that section via Apple's feedback page, if you wish:
    http://www.apple.com/feedback/itunesapp.html
    It's been removed before and then reinstated, so it's possible they'll bring it back.
    Regards.

Maybe you are looking for

  • HP All in one Volume bar error

    Helloo, i have a hp all in one pc ..........from 3-4 days it is resulting a blue volume bar when ever i put the volume up or down from the keyboard .........i have tried to change my settings but unfortunately its not done..................... so plz

  • HT2188 my iphone is not coming up in itunes under devices

    When i plug in my iphone to computer i am no longer seeing ''devices'' in list and so i cannot sync my iphone, any ideas??

  • AFP / Profile Manager / Wiki problems Lion OSx 10.8.5 Server 2.2.2

    I experience strange problems with our AFP sessions after upgrading to 10.8.5 / 2.2.2 where sessions will hang and a second session is opened. Users log out correctly. Seems that iMacs coming out of sleep mode are having this issue more then the ones

  • Swing is great !!!!!

    Hi guys I've been working in swing for a last 5 years developing a client server and a GUI library. I've been working in coding our java beans (MyJTable, MyPopupDataTextField etc,etc) and our data JDBC beans. The only thing I could say now is that th

  • Can't reconnect 'missing' photos

    After importing all my photos from PS Elements 8, taking the suggested defaults, I was presented in the Library grids many cells with the broken icon in the upper rh corner. Upon running the 'Find Missing Photos', I received a report saying there are