How can I shorten it to a small function?
I have a simple function that does the conversions, but I know there is a better way to do it besides using a bunch of otherwise if statements. How I shorten it?
private function doConversions(value:int):void { if (selectedFromSpinner == "acres" && selectedToSpinner == "hectares") { txtOutput.text = (value * 0.404686).toString(); } else if (selectedFromSpinner == "hectares" && selectedToSpinner == "acres") { txtOutput.text = (value * 2.47105381).toString(); } else if (selectedFromSpinner == "ares" && selectedToSpinner == "acres") { txtOutput.text = (value * 0.0247105381).toString(); } else if (selectedFromSpinner == "acres" && selectedToSpinner == "ares") { txtOutput.text = (value * 40.4685642).toString(); } }
Thank you
You could probably make a little shorter with the help of a dictionary, but it would be probably slower.
Basically, you'd do a table of implementation "" elements, each of which contains a table of "to the" elements, each having a multiplication factor. Then for each conversion, just look up the correct entries.
You might speed it up by using integers instead of research/string comparisons.
Alternatively, standardize to a single device: first convert everything in m2, and then convert the m2 in everything. That would make it much easier to maintain your code. Off the top of my head and not verified:
// on app initialization: var toM2:Array = []; toM2['acres'] = somefactor; toM2['hectares'] = someotherfactor; // etc
// for conversion: var m2:Number = value * toM2[selectedFromSpinner]; // convert to m2 txtOutput.text = m2 * (1/toM2[selectedToSpinner]); // convert from m2
Tags: BlackBerry Developers
Similar Questions
-
How can I get rid of the small spinning color wheel?
How can I get rid of the small spinning color wheel?
Article useful here on the causes of the spinning Beach Ball, and how to fix it:
and also this:
-
How can I get rid of a small white rectangle that stays on my screen and it also does not allow me to turn off my computer?
Hello
1. Since when are you facing this problem?
2. have there recent changes or updates made on your computer?
3. do you get an error message?
4. what happens when you try to shut down the computer?
5. What is the small white rectangle you speak?
Method 1:
Step 1:
Try restarting your computer in safe mode and check if the problem persists.
If it works fine in safe mode try performing a clean boot in order to find the cause root.
Step 2:
See the article below for instructions on how to start your computer in a clean boot state.
How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
http://support.Microsoft.com/kb/929135Note: When the diagnosis is complete, don't forget to reset your computer to normal startup. Follow step 7 in the above article.
Method 2:
Try to run Microsoft Safety Scanner for any malware or spyware infection and check if it helps.
http://www.Microsoft.com/security/scanner/en-us/default.aspx
-
How can I shorten a part of the animation?
I'm kinda a noob Flash, so apologies if the answer to that is blinding!
In Flash CS6, I need to shorten a time line animation article. Y at - it an option to do this?
The film is set to run at 30 frames per second, but increase the pace is not the solution.
For example, a section of the animation runs currently 5 seconds (that is to say, is long of 150 executives) and contains a large number of interpolations.
How can I shorten it so that the entire sequence runs in 4 seconds (that is to say, long 120 executives)?
Thank you.
If they are interpolations of movement, you can grab the end of each one and drag it to be posted on the 120 frame. Other keyframes will scale accordingly.
If they are classic tweens, you can remove some of the difference images to gather images-keys more closely. It may take some time!
-
How can I get the date and time function to appear as a tile
How can I get the date and time function to appear as a tile
How can I get the date and time function to appear as a tile
WIN8 are delivered with this tile/app. The only way to display the time is to launch the charm bar (Win - key + C) or mouse over to the right up/down. That said go to the Windows store... There are several free applications that display the time / date as a live tile. Good luck.
-
How can I change my font from small to large size?
I jused to have a normal size fonts to send & received messaged. The size of the font has become very important for a week. Then the font size is too small. How can I get this back to being reqdable. Say where to start.
Hi, John.
Always be specific in detail when you post a question. It helps to find solutions.
. Suggestions for a question on the help forums
http://support.Microsoft.com/kb/555375
This is for Windows Mail?
- On the Windows Live Mail tab, click Options , click mail.
- On the read tab, click fonts.
- In the box, the font size , select the small, medium, large, and then click OK.
- Click OK to close the Options dialog box.
Press Alt > select view > text size > select the choice of size
This increases the text size in your web browser
Right click on desktop
Select Customize
Appearance and select Windows Color
Select Open Classic properties of several color options
Click on the Advanced button
Select the icon of the menu drop-down
Select font of choice
Select the font size
Select the bold or italic
This will change the font used on your icons, tabs, as well as messages
Press Ok
Wait for the changes to take effect
Press on apply, Ok
-
How can I get rid of the small window of Action Center?
How can I get rid of the window of Action Center? I read Center wants to tell me what action and you click on the x in the upper right of the window that appears when you open the center of the action, but I have a small window at the bottom right which is above any other window, and I want to get rid of it. It is not an x or a close button. How can I get rid of this horse?
Before this problem, when I started to Win 7 me a choice of normal startup or a 'safe mode' start because he thought that I had recently installed a device that caused a problem. Windows tried to solve the problem but says have failed, and then I was able to start windows normally. I have not recently (last days) installed anything, but the PC is about 2 weeks old, and I have installed things like an external usb drive, a printer, a flash drive, an mp3 player and a wireless mouse.
Maddog1381,
Check out this TechNet article that describes how to disable the pop-ups Action Center:
http://TechNet.Microsoft.com/en-us/magazine/dd492018.aspx
I hope this helps!
Cody C
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think. -
How can O6 money, I make the smaller account page
When I print the page accounts of the last column on the right is too long and printed on a second page. How can I get the page to print it on one page?
Change the settings for printer in landscape mode. BTW, it really is time to move to another financial program. The money has been abandoned for years. Try Quicken.
-
How can I disable the unique - Fn key function keys?
I have a new Dell with Win 7 laptop, and the volume control function keys, reading, etc. when they are pushed to him only (without the need to push the Fn key at the same time). The problem is that I use these keys only to other purposes more how to adjust the volume, etc. For example, in MS Publisher, I Zoom in and out to 100% by pressing F9. However, as it is now I have to press Fn and F9 for this.
How can I change this back to the 'old' where you need Fn most key to do all what indicates the icon on the function key? As the volume, check the battery, brightness, etc.
I searched on help for Win 7 without success.
Thanks for your help. Bob
For any question on Windows 7:
http://social.answers.Microsoft.com/forums/en-us/category/Windows7
Link above is Windows 7 Forum for questions on Windows 7.
Windows 7 questions should be directed to the it.
You are in the Vista Forums.
See you soon.
Mick Murphy - Microsoft partner
-
How can S2340T, I turn off the touch function?
I am running the S2340T monitor on a Windows Pro 8.1 System. Touch calibration occasionally goes haywire, but I've always been able to open the tool pen and Touch and recalibrate. Except that now, it doesn't seem to be "holding".
As I rarely use the tactile aspect of the screen and am completely comfortable with my trackball mouse, I would just turn the tactile aspect * off *.
How can I do this? I know that you go to the Device Manager, but how to know what 'Human Interface' element it is? I'm a gamer, so I have a * lot * of human interface elements.
Thank you!
Disconnect the monitor cable computer USB upstream will turn off the monitor to "touch" feature This means that you will not be able to use one of the USB ports monitor downstream.
-
How can I get a value from a function from pl/sql by OADBTransaction
Hi all
Hope you will be fine.
as we know, we can get a sequence by this code value:
Super.Create (AttributeList);
Transaction OADBTransaction = getOADBTransaction();
Vendor ID is obtained from the table sequence
Number supplierId = transaction.getSequenceValue ("FWK_TBX_SUPPLIERS_S");
My question is how can I get a value in a variable to a pl/sql function:
the function is defined as follows:
******
create or replace function getNextTrans return varchar2
is
Team varchar2 (20);
Start
SELECT "CASH". TO_CHAR (SYSDATE, 'DDMMYYYY') | GP_CASH_TRX_SEQ. NEXTVAL FROM DUAL;
return team;
end;
/Hey Dina,
Reference http://www.oraclearea51.com/oracle-technical-articles/oa-framework/229-calling-database-procedures-and-function-from-oaf.html
Kind regards
GYAN -
How can I make my items from smaller office? They are all real great.
All my desktop icons are real big. The resolution of the screen is ok, but all my shortcuts are enormous. I can't understand how to make them a normal size.
Hold down the Ctrl key and rotate the mouse wheel.
-
How can I make my desktop icons smaller?
I have expanded my desktop icons and I can't find where I did, to windows Explorer or control panel or the Center home. I want to return to their original size
Hello
Right click on the desktop - display - select size.
I hope this helps.
-
How can I make my web page smaller?
I don't know there's a very simple answer to this topic - when I saw my Web page in a browser, it takes up the entire page. Is there a way I can reduce it so that there may be an inch or two between the content and the edge of the browser? I hope there is an easy answer which will also scale all content as well, so I don't have to change their sizes.
Right. Th CSS code with background-size: cover is re-scaling of your background image to fill the whole window. Really, you must add the prefixes of the seller for older browsers.
When used correctly, it can give good results. See the example below. Resize your window to display.
ALT-Web: discoloration of loading the demo Page
{body
background: url(images/background.jpg) Center set;
/ * Safari & Chrome * /.
-webkit-background-size: cover;
/ * Firefox * /.
-moz-background-size: cover;/ * Opera * /.
-o-background-size: cover;/ * MS IE * /.
-ms-background-size: coverage;
/ * for any other browser * /.
background-size: cover;}
Nancy O.
-
How can I make an imported picture smaller without changing the size of the canvas?
After downloading the free icons, I used the method drag-and - déposer to put the icon of my choice on a blank canvas of 313 x 188 pixels. The image is larger that I need it to be, so I need to make the image smaller while keeping the size of the canvas to 313 x 188 pixels. I tried several things after Google search, but have had no luck. Help; I'm still learning! Thanks in advance!
CTRL/cmd-T will show the transformation. Then just drag the handles to resize - hold down the SHIFT key to constrain the proportions.
Maybe you are looking for
-
TB check gmail, said there are 88 messages then download any.
For some reason any TB stop working with gmail. It goes on the site, says there are 88 messages then will then send. I have unread messages in gmail. I put gmail to delete messages when they are downloaded from the server and it does not happen eithe
-
Windows starts only in safe mode after refomatting
I reformatted computer my husband, during the process of re-setup the computer shut down & restarted in safe mode. I can't the computer to start Windows normally, it starts only in safe mode or at least what looks like safe mode. I am trying to insta
-
Best network and bluetooth driver
Hello. I have a hp probook 450 G0 - G1 without a network or Bluetooth drivers. Which would be the best driver to install on your site?
-
Error 0xc18a0306 in the HP D7200 series
I get this error 0xc18a0306 when I start my printer... My ink cartridges are new. What can I do?
-
error c000021a fatal systrm then 0 x 00000000 (0xc00000001 0x00010037c)
Open windows 7 Dungeon carn can't get repair system recovery I do, but anything said itjust Startup Repair cannot repair this computer automatically