The operators display
For the calculator that I've created, I had until now all the buttons d entry in the display such as the numbers and operators. However for operators when trying to store the value in two variables 'num1' and 'num2', I traced to test whether they worked very well however they came out as "NaN". Here is the code I have so far and the highlighted area is what I'm currently working
import flash.events.MouseEvent; var btn:Array = new Array(); for(var i = 0; i < 10; i++) { var myBtn:Btn = new Btn(); myBtn.y = 15; myBtn.x = i * 100 + 15; myBtn.width = 48; myBtn.height = 48; myBtn.buttonMode = true; myBtn.mouseChildren = false; myBtn.num = Number(i); myBtn.caption.text = String (i); addChild(myBtn); btn.push(myBtn); btn[i].addEventListener(MouseEvent.CLICK,pressNumber);//EVENT TO ADD NUMBERS TO DISPLAY } btn[0].y += 370; btn[0].x += 10; btn[1].y += 310; btn[1].x += -90; btn[2].y += 310; btn[2].x += -130; btn[3].y += 310; btn[3].x += -170; btn[4].y += 250; btn[4].x += -390; btn[5].y += 250; btn[5].x += -430; btn[6].y += 250; btn[6].x += -470; btn[7].y += 190; btn[7].x += -690; btn[8].y += 190; btn[8].x += -730; btn[9].y += 190; btn[9].x += -770; //OPERATORS// var operators:Array = new Array(); for(var io:int = 0; io < 6; io++) { var opBtn:Btn_operator = new Btn_operator(); opBtn.width = 48; opBtn.height = 48; opBtn.buttonMode = true; opBtn.mouseChildren = false; opBtn.caption_op.text = String ("."); addChild(opBtn); operators.push(opBtn); operators[io].addEventListener(MouseEvent.CLICK, pressOperator);//EVENT TO ADD OPERATORS TO DISPLAY } //ADD DOT var dot:Btn_dot = new Btn_dot(); dot.width = 48; dot.height = 48; dot.buttonMode = true; dot.mouseChildren = false; dot.caption_op.text = String ("."); addChild(dot); dot.y += 383; dot.x += 78; dot.addEventListener(MouseEvent.CLICK, addDot);//EVENT TO ADD DOT TO DISPLAY //BACKSPACE var goBack:Btn_backspace = new Btn_backspace(); goBack.width = 48; goBack.height = 48; goBack.buttonMode = true; goBack.mouseChildren = false; goBack.caption_op.text = String ("<--"); addChild(goBack); goBack.y += 203; goBack.x += 256; goBack.addEventListener(MouseEvent.CLICK, backSpace);//EVENT TO GO BACK SPACE IN DISPLAY //BACKSPACE var clearAll:Btn_clear = new Btn_clear(); clearAll.width = 48; clearAll.height = 48; clearAll.buttonMode = true; clearAll.mouseChildren = false; clearAll.caption_op.text = String ("C"); addChild(clearAll); clearAll.y += 323; clearAll.x += 256; clearAll.addEventListener(MouseEvent.CLICK, clearFields);//EVENT TO GO BACK SPACE IN DISPLAY operators[0].y += 383; operators[0].x += 138; operators[0].caption_op.text = String("="); operators[1].y += 383; operators[1].x += 198; operators[1].caption_op.text = String("/"); operators[2].y += 323; operators[2].x += 198; operators[2].caption_op.text = String("*"); operators[3].y += 263; operators[3].x += 198; operators[3].caption_op.text = String("-"); operators[4].y += 203; operators[4].x += 198; operators[4].caption_op.text = String("+"); operators[5].y += 263; operators[5].x += 256; operators[5].caption_op.text = String("-/+"); //VARIABLE HANDLE OPERATION NOT BUTTON var operate:String; //HANDLE FIRST AND SECOND VALUE var num1:Number; var num2:Number; //grouping all buttons in function //display_txt.text = "0"; //DISPLAYING NUMBERS IN DISPLAY //var numberEntered:String =""; function pressNumber(e:MouseEvent):void{ display_txt.appendText(e.target.num); } //DISPLAY OPERATORS function pressOperator(event:MouseEvent):void{ var operatorEntered:String; display_txt.appendText(event.currentTarget.caption_op.text); //CHECKING FOR VALUES AND STORING NUMBERS if(!num1){ //CONVERT STRING TO NUMBER num1=Number(display_txt.text); operate = operatorEntered; trace(num1); display_txt.text = ""; } else if(!num2){ num2 = Number(display_txt.text); performCalculation(); operate = operatorEntered; } } //CLEARS DISPLAY AREA function clearFields(event:MouseEvent):void{ display_txt.text = ""; num1=NaN; num2=NaN; } //ADDS DECIMAL PLACE function addDot(event:MouseEvent):void{ if (display_txt.text.indexOf(".")==-1){ display_txt.appendText("."); } } //BACKSPACE DISPLAY AREA function backSpace(e:MouseEvent):void{ var temp_str:String = display_txt.text; display_txt.text = temp_str.substr(0, (temp_str.length-1)); // Get rid of last character in the string, which in this case is the phantom \r or \n character } function performCalculation():void{ switch (operate){ case "multiply": num1*=num2; break; case "divide": num1/=num2; break; case "subtract": num1-=num2; break; case "add": num1+=num2; break; default: break; } //now that we found out the result //let's display on the window display_txt.text=String(num1); num2=NaN; }
I need to see if the number is stored when I click on operator d. In the trace, it is supposed to display the number entered after I click on an operator, but it displays as "NaN" I guess all of this function has errors. This is the pressOperator function, I work with that
Post edited by: ay5ha
use:
var currentNumber:String =""; function pressNumber(e:MouseEvent):void{ display_txt.appendText(e.target.num); currentNumber+=e.target.num; }
Tags: Adobe Animate
Similar Questions
-
I use a vertical dock for awhile, so my MBPro retina works in closed with external display, KB and mouse display mode.
But since I installed the update of the Sierra, the external display not Mac OS desktop.
It only works when I open the built-in screen...
The bug is known? Or y at - it a setting to adjust on the Sierra?
Thank you in advance
Hi darklemon,
I understand that, since the update to Mac OS Sierra, you've been unable to use your MacBook Pro in closed view. I know it's important to use your computer in a way that suits you, then I'm happy to help you.
Let's start by resetting your memory NVRAM and SMC which can often help with system display and related issues:
How to reset the NVRAM on your Mac - Apple Support
Reset the management system (SCM) controller on your Mac - Apple SupportOnce you have done this, follow the steps here to set up the closed display mode:
Use your Mac laptop to view closed with an external display - Apple Support
Thank you for using communities Support from Apple. See you soon!
-
I tried to erase and reset my iphone 6 s. But why is it taking so long? For more than 24 hours. Is this normal? The phone displays just the apple logo and wont open. Help, please. Thank you in advance.
Hello
Follow the instructions here:
If you are unable to update or restore your iPhone, iPad or iPod touch - Apple supports
-
How can I disable the newtab most used feature display sites. I want the new tab to open the page displayed in the newtab:url in the topic: function config
41 of Firefox is no longer uses the browser.newtab.url setting in about: config because he was constantly attacked by malware. From 41 of Firefox, you need an add-on to change the new tab page.
Here are a few options (I'm learning more all the time):
- If you are already using the extension classic restaurateur theme: There is an option somewhere (!) in his dialogues of the parameters to select another page in the new tab.
- If you want to use your new tab homepage: Try https://addons.mozilla.org/firefox/addon/new-tab-homepage/
- If you want to set another page or a completely blank page: Try https://addons.mozilla.org/firefox/addon/new-tab-override/
Setting up substitute again tab
After installing this extension, you must use the Options page to set the new desired tab page (instead of use subject: config).
Open the page modules using either:
- CTRL + SHIFT + a (Mac: Cmd + shift + a)
- "3-bar" menu button (or tools) > Add-ons
In the left column, click Extensions. Then on the side right, find the new tab override and click the Options button. (See first screenshot attached).
Depending on the size of your screen, you may need to scroll down to enter the address in the form. (See second screenshot attached). For example:
- (Default) page thumbnails = > subject: newtab
- Blank tab = > subject: empty
- Built-in Firefox homepage = > topic: welcome
- Any other page = > full URL of the page
Then tab or click this form field and you can test using Ctrl + t.
Success?
Once you have set it as you wish, you can close the Add-ons page (or use the back button to return to the list of Extensions of this Options page).
-
Which side is the usb port 3 on a 2015 macbook pro with the retina display?
Which side is the usb port 3 on a 2015 macbook pro with the retina display?
I found the answer. It's the left side near the microphone.
-
How can I change the color of the fonts displayed on Firefox itself?
Not Web sites; I know how to change the font style and color used on Web sites. What I was asking is how to change the color of the font of the text displayed on the interface of Firefox itself. Specifically, I want to change the font of the text '100% ' at the top of the Zoom option, since I have no idea when or how it changed (could be me; I do remember never do, however); I have attached a screenshot for better reference.
I was wondering, but did not before, if it remains green if you move to another bar. In other words, is there something special about this area of bar bar/menu top of the title page which affects the color of the font.
-
I am in yahoo mail and there is a window that has the windows displayed and I can click on one of the images of a window and it will restore the window how to access this window (size full one who possesses a collection of previous windows in a complete graph/no format)?
The window that I write the topic is a collection of previous windows images in a smaller size.Firefox has a feature to view all your open tabs in one or more groups of tabs. You can show and hide this screen by pressing Ctrl + Shift + e. Is this the one you see, or something different?
If you ended up with more than a group of tabs and you want to consolidate them, you can drag the thumbnail images all in one group.
More information: use tab groups to organize a large number of tabs.
-
RE: Thunderbird email list
I like to see the columns 'Date' and 'receipt '. I noticed that the time displayed is exactly the same in both columns, and I knew from Outlook it wasn't normal. When I checked the headers, I found that Thunderbird did not display the received time, but rather, in all cases, it is at once sent. Here is an example:
The last "Received" line in the header is: (> > added)
> > received: by 10.216.205.198 with SMTP id j48csp33972weo;
> > Thu, May 22, 2014 07:25:10-0700 (PDT)The other relevant line is:
> > date: Thu, May 22, 2014 14:21:21 + 0000Note that there is difference of 4 minutes which is not too uncommon, but 09:21 for the two columns is displayed. It is sent in good time, but not the good received on time. It should display at 09:25 in this column.
http://blog.dmitryleskov.com/small-hacks/putting-the-received-column-in-Thunderbird-to-work/
-
The "issue" essentially lines the problem.
No distance shows content when the user clicks on the button "view remote content. Once it has been clicked on a specific email, if I go back to the same email, the button "display remote content" is not on the e-mail page and no remote content shows again in the body of the email.
I use an updated version (24.4.0) of Thunderbird.The problem is often caused by anti programs anti-virus and other security software blocking Thunderbird to get the remote images. The GET for images using a web port usually and some security software not see Thunderbird as a browser and block access.
-
shortcut to open all the triangles display in the historic Safari menu
When in the ' to see the ' in safari my complete story collapsed in daily triangles to display... y at - it a shortcut to open all the triangles display? Click option does not work.
rscottd wrote:
When in the ' to see the ' in safari my complete story collapsed in daily triangles to display... y at - it a shortcut to open all the triangles display? Click option does not work.
I don't know any way to do it.
Feedback: Apple http://www.apple.com/feedback/
-
Here is the chronology of the events:
(1) FF start on my MBP (OS 10.8.2) and the retina display working properly.
(2) connect my MBP to a 24 "external display which has a resolution of 1920 x 1200 (defined as primary) max. FF displays well on screen.
(3) disconnect the external display and FF is now pixel on retina MBP. Updating of system preferences Dispay doesn't seem to help, or I have not found the magic technique.
(4) restart FF and everything is fine.
The question seems so FF not to recognize the need to revisit the resolution of the retina.
You are welcome
-
Hello!
The new version of Firefox, I have a problem with the opening of the site VKontakte. The browser displays the following error message: "Firefox has determined that the server redirects the request for this address in a way that it will never end." How to solve this problem? Please excuse me for my English.
Sincerely, Vsevolod.This can be caused by corrupted cookies or cookies that are not sent or otherwise blocked.
Clear the cache and cookies from sites that cause problems.
"Clear the Cache":
- Tools > Options > advanced > network > content caching Web: 'clear now '.
'Delete Cookies' sites causing problems:
- Tools > Options > privacy > Cookies: "show the Cookies".
See also:
-
The player display DVD Toshiba C855D satellite ceased suddenly display
Please help as its now beyond me. The DVD player has suddenly just stopped. I can hear it and control it but can't see it. I checked the button display but its all ok.
Help
Sorry, but your applicant is very confusing
I have no idea what you changed in the settings of the DVD from Toshiba player in the past, but I think the simplest solution would be the new installation of a utility DVD Toshiba drive.Usually you can download page of the Toshiba UE driver Toshiba DVD player
Before installing this software, I recommend to uninstall the installed Toshiba DVD player.
Reboot the laptop.
Download the tool on the Toshiba site and start the installation.
Finally, restart the laptop and test functionality. -
Satellite M50-130: no display after the passage of the external display in main monitor
I have a very strange problem.
My brother was on his user space as soon as possible and I managed to get the secondary monitor for main monitor and disable the screen of the laptop back, however, when it comes to me, it won't happen...Well, any help would be appreiciated.
Hello
Could you please be clearer? Is it possible to see something on the external monitor?
Do you see something? What happens if you use the function FN + F5 device display?I put t know how you managed to set the external display as main screen because on my laptop, this option is grayed out.
However, you should see the laptop if you will start Notepad in safe mode. Please check! -
The window display all bookmarks and bookmark side are empty, even though my booksmarks are always accessible from the Firebox menu > bookmarks. Unfortunately, I can't manage my favorites through this option. How can I fix the windows display all bookmarks and Favorites aside to display my favorites?
One possible cause is a problem with the places.sqlite file that stores the bookmarks and history.
Maybe you are looking for
-
Emails have been sent, but I was not yet connected to both.
2 emails were sent on 11 / 25 at 14:15. I was not connected at the time. I do not keep open e-mail, I close every time that I leave.A single e-mail copied a zip file that I had sent to my nephew in an e-mail of 10/05/2011; He sent me it. The e-mail s
-
HP Officejet Pro 8600 Plus - printing of Documents for glass copy and charger slowly
We bought this printer a few months back, and everything was working great. Yesterday afternoon, the COPY works, the high plateau of the loader page or the scanning tray, from work extremely slow. If I put a document on the glass and do a preview, it
-
"You must format the disk in drive g before you can use it"
"You need to format the disk in drive g before you can use it... "Really crappy to get Msg. I have a Corsair 16 GB FAT drive. I got the disc from my Vista computer and go to a XP machine safely. Aaarrrggghhh! New tips on how to solve this problem?
-
1330 error when you try to install the software main street
Receive the following error message when you try to install the update of the software of Boulevard of Main Street Software, Inc. 2011 on a machine running Windows Vista 64 bit HP. File 1330.A error required cannot be installed because the file E:\Bl
-
3050 J611a has stopped free wireless
I got my printer put in place and works wirelessly for several months, then all of a sudden it stopped - I don't think that something has changed on my network, it seems to be the printer. I tried to re-login via WPS, but the reports WPS printer erro