Getting a 0 when converting text to a number. need help.

Hello world

I am in 2nd year CS design my 1st app for blackberry. I use the code provided by RIM as my starting base.

My problem is that when I convert a text in a number input using parseInt (foo.text) or (foo.text) Number I have a 0 instead of the number entered by the user. Here is the code I wrote for user input:

var myInput:TextField = new TextField();
addChild (myInput);
            
myInput.type = "input";
myInput.border = true;
myInput.x = 140;
myInput.y = 40;
myInput.width = 125;
myInput.height = 20;

var n: Number = Number (myInput.text);

var ntring = String (myInput.text);

var firstnum = Number (n);
trace (n);

the trace function returns a 0. I also tried this:

var firstnum:TextInput = new TextInput();
newUfirstnum.width = 200;
newfirstnum.x = 140;
newUfirstnum.y = 65;
newfirstnum. Height = 20;
addChild (firstnum);

var input: int = parseInt (firstnum.text);

trace (Input);

Does anyone know why I get a 0 and what I can do about it? Any advice would be helpful.

Thank you.

Hey,.

just a follow-up in case you're having trouble, here is a working application that uses the same variables as you did. It is an object TextInput (QNX) and a tag button that click you on to see what the variable text in the TextInput object. When you click on it will trace the value in the debugger:

package
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.MouseEvent;

    import qnx.ui.buttons.LabelButton;
    import qnx.ui.text.TextInput;

    [SWF(width="1024",height="600",backgroundColor="#CCCCCC",frameRate="30")]
    public class TextInputTest extends Sprite
    {
        /**
         *
         * Place your variables outside of the constructor
         * it makes it easier to work with when using
         * other functions like listener functions
         *
         */
        private var firstnum:TextInput;
        private var myBtn:LabelButton;

        public function TextInputTest()
        {
            super();

            // support autoOrients
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;

            /**
             * Create your TextInput object just as you did
             * before, only this time we wont try to trace
             * the data in it right away
             */

            firstnum = new TextInput();

            firstnum.width = 200;
            firstnum.x = 140;
            firstnum.y = 65;
            firstnum.height = 52;

            addChild(firstnum);

            /**
             * We are going to create a label button
             * that allows us to listen for a MouseEvent.CLICK
             * (mouse click) that will tell the application
             * to trace out our data
             *
             */

            myBtn = new LabelButton();
            myBtn.label = "Trace!";
            myBtn.setSize(150,52);
            myBtn.setPosition(375, 65);

            /**
             * This is the important line, to add a listener. We
             * tell the application to add a mouse click event
             * listener and we will run the onClick function when
             * there is a click
             *
             */

            myBtn.addEventListener(MouseEvent.CLICK, onClick);

            addChild(myBtn);
        }

        private function onClick(e:MouseEvent):void
        {
            /**
             *
             * here is where we will do our conversion and
             * output via the trace function
             *
             */

            var input:int = parseInt(firstnum.text);

            trace(input);
        }

    }
}

I've inserted comments to help you along the way. also, I want that you notice that ActionScript (Adobe AIR) is all based event. Therefore, use events and listeners to get things moving. hope that helps a little more. Good luck!

Tags: BlackBerry Developers

Similar Questions

  • Possibility to have a heading row when converting text to a table?

    using CS6

    Unless im having a brain lapse and giving fully on something, I think that there is no way to do that, except perhaps in script. I looked around and found no similar post everywhere or the other.

    I have all my styles of table cell / linked in the other properly I can prove it because if I'm going to get a bunch of new table everything works as I want only it.

    My guess is that the culprit of the problem is that there is no option to specify the headers (amount/location) in the conversion dialog box the text table. A simple check with box and the ability to "make the first line a header" would suffice even. I don't know how it would be difficult to modify the dialog box itself and add this option. (my guess is that its pretty difficult/intrusive to the program).

    I know that I can easily highlight the line and then simply apply the style I did for the header of the table, but the documents I did tend to have a lot many tables. This would be / is horrible to change if someone or me decides to make style changes to multiple documents.

    So my next thought was perhaps a script could help out me.

    something like:

    1. find all tables with a specified table style.

    2. change the first line for all the tables which follow the rule 1 in a header line. (For this table header cell style must be updated to take into account all that is called for in the style of table.)

    [Because table style settings have an option to specify the style of cell in a row of header inside the table, im thinking it must so far do.]

    only one problem, I fell on trying to do it manually, is that when I take a table and you try to add a header that makes him a completely new line on top of the table. So if you were to copy all text in the line I was using as a header and then paste in the newly added header line that it does not work because it keeps the style that never has been copied. leaving your only option to re-type all headers and remove all the old ones (YUCK!).

    I am open to suggestions but I confess that I don't know what anyone on the scripts.

    I understand that this is perhaps a kind of vast demand but no help is not provided and greatly appreciated!

    Thank you for your time and I apologize for the big enough position.

    Sorry, I'm bored a bresh curlly

    Now try this

    var table = app.documents [0].stories.everyItem ().tables.everyItem () .getElements ();

    for (var t = 0; table.length > t; t ++) {}

    for (var r = 0; table [t].rows.length > r; r ++) {}

    try {}

    {if(r==0)}

    for (var c = 0; table [t] Rows [r].cells.length > c; c ++)

    {

    [t] [r] table of Rows .cells [c] .appliedCellStyle = "cell Style 1.

    }

    }

    }

    {catch (e)}

    alert (e)

    }

    }

    }

  • I get error 87 when I try to download creative cloud, help?

    For some reason any creative cloud uninstalled in a way because it's not on my apps and when I try to download CC I get code error 87. He said that another installer was running and I don't suppose it was adblock that I disabled it for the site. I have not reached out to support chat again, but I decided to try to see if the forums could help out me.

    Hello

    Some windows updates are running on your machine in the background that block the installation. If please restart your machine and try again. This should solve the problem.

    Thank you

    Rohit

  • Text editor and setTextFormat (need help)

    Hello

    I created a text editor in AS3 to administer a site online, but I have a problem when I select a Word, put in bold, save the text and load, all the text after that this word becomes too "BOLD". (a bold word I select this world and use a button that transform this word in bold)
    (I'm sorry if my English is not very good, I'm french)

    Here is my code

    var formatGlobal12:TextFormat = new TextFormat ("_serif", 12);
    txt_references_springbok_fr.setTextFormat (formatGlobal12);
    
    var formatSelection12:TextFormat = new TextFormat ("_serif", 12);
    formatSelection12.bold=true
    formatSelection12.leading=0
    function appliquerFormatSurSelection12 (e:MouseEvent):void
    {
            txt_references_springbok_fr.setTextFormat (formatSelection12, txt_references_springbok_fr.selectionBeginIndex, txt_references_springbok_fr.selectionEndIndex);
    }
    
    boutonAppliquer.addEventListener (MouseEvent.CLICK, appliquerFormatSurSelection12);

    $template_debut ="

    .. and add the CDATA end closure

  • fade out dynamic text only fading. Need help with actionscript

    Hi all

    I hope someone can help me. I have a dynamic text I want to fade and then fade out and then disappear in another bit of copy. My text fades but is not melted, paragraph disappears and then evokes the next paragraph suddenly. All the basic ideas on the code that I have attached here? Let me know if you need more.

    Thanks a lot for your help. I finally found it and done in a much simpler way with much less code. I used symbols that I mentioned in previous posts, following this same actionscript help basis but put my video clips on frame 1, used a stop action and ended up with PlayMC()

  • Firefox will not update on my Mac Pro. After reboot, I get the message to update available again. I need help?

    After each attempt to update and restart, Firefox will never update to the new version. I'm still at version 34.0.5.

    Hello!

    Some Firefox problems can be solved by performing a clean reinstall. This means that you remove Firefox program files, and then reinstall Firefox. Please follow these steps:

    Note: You can print these steps or consult them in another browser.

    1. Download the latest version of Firefox from mozilla.org office (or choose the download for your operating system and language on this page) and save the file to install it on your computer.
    2. Once the download is complete, close all Firefox Windows (or open the Firefox menu

      Click the close button

      ).

    3. Remove the Firefox installation folder, which is located in one of these locations, by default:
      • Windows:

        • C:\Program Files\Mozilla Firefox
        • C:\Program Files (x 86) \Mozilla Firefox
      • Mac: Delete Firefox in the Applications folder.
      • Linux: If you have installed Firefox with the distribution-based package manager, you must use the same way to uninstall: see Install Firefox on Linux. If you have downloaded and installed the binary package from the Firefox download page, simply remove the folder firefox in your home directory.
    4. Now, go ahead and reinstall Firefox:
      1. Double-click on the downloaded Setup file and go through the steps in the installation wizard.
      2. Once the wizard is completed, click to open Firefox directly after clicking the Finish button.

    More information on the resettlement of Firefox can be found here.

    WARNING: Do not use an uninstaller to third parties as part of this process. This could permanently delete your Firefox profile data, including but not limited to, extensions, cache, cookies, bookmarks, personal settings and passwords saved. They can be retrieved easily unless they have been backed up on an external device! See back up and restore the information contained in the profiles of Firefox.

    Please report to say if this helped you!

    Thank you.

  • I can remove the attached to my iPhone apple ID *... ghoulish remove this on my record. Another problem when text to this number * it back to my number 760

    I can't remove this for my iPhone apple ID * is attach to my iPhone, second question when I text to this number *, returned to my number, how can offer to this number... Thant you if you can solve my problems.

    I have no idea what you're talking about.  Perhaps you can rephrase with the correct spelling and actual phrases that include capital letters and periods, and other grammatical subtleties.

  • my bit defender can't seem to get rid of malware called OSX/InstallMiez need help

    I have a Mac with OSX EL Capitan my bit defender 2014 I can't seem to get rid of malware called OSX/InstallMiez.

    Need help thanks in advance

    I don't know this type of malicious software, but you can try to get rid of with one of these applications (free and safe):

    https://www.Malwarebytes.com/antimalware/Mac/

    http://etrecheck.com/

  • I no longer get suggested words when composing a message text on my iphone 5.  How to get back to get this function works

    I no longer get suggested words when composing a message text on my iphone 5.  How to get back to get this function works

    Make sure that the text is on. You can do this on the keyboard (if you have several) by pressing and holding down the button to change between them.

    Alternatively you can go to settings > general > keyboard and make sure predictive is turned on (the switch must be green).

    If you see the image below, press the small white bar above the buttons T and Y and slide upward slightly.

  • In indesign when the text is converted to be vectorised text, underlined text effect is not preserved

    In indesign when the text is converted to be vectorised text, underlined text effect is not preserved

    Adobe recommends strongly against systematically vectorised text conversion as being an unwise practice, destroyer of workflow, there is a very simple correction in Acrobat DC Pro control upstream that makes these conversions in one step.

    -Dov

  • I get an error message of complete storage - please backup and remove your something online (can not see the full error message) when converting PDF reader to point rower inacrobat DC. Help, please

    I get an error message of complete storage - please backup and remove your something online (can not see the full error message) when converting PDF reader to point rower inacrobat DC. Help, please

    Hi debg25514049,

    You will not be able to export your PDF to PPT using the service Adobe export in PDF format.

    You'll need subscription to pack Adobe PDF or the Acrobat application to convert PDF to PPT.

    Kind regards
    Nicos

  • The stroke disappears when I convert text to outline

    I have a type used to describe another type layer. The bottom layer has a run of 8 - pt. But the police cause 'o' to have a point wandering in the upper part. But, when I convert the text to outlines, the race goes and I find myself with the guy who is not sufficiently wide or high.

    (The scaling for the height and width does not have the same effect we're looking for. Unfortunately I'm working on the files of my predecessor, so I have to give the impression that this was the case).

    Any help would be appreciated. I work in ID CS3 and don't really want to create in another program and then import it.

    Thank you.

    Remove the line before converting text outlines. Then add the race after that you described.

  • Get the position of the text (inside or outside a nightclub?)

    Hi all

    I use simple Ruby to access the contents of a PDF file. This help PDF Reader of yob of GitHub.

    Now, I've come a long way, but still have a question that remains! How to get the position of a text object (this object area)?

    I read the PDF reference, he told me all sorts of things on the text area, space glyph and user... As English is not my mother tongue, there is a lot to take... I currently have a Community trade mark, a matrix of text and text rendering matrix. I have also all the boxes on the page (media, trim, culture etc..)

    For an Image object, I use the values of e and f CTM as x and y. It works perfectly, but when it comes to text, seems to be missing something...

    Example:

    CTM: Matrix]

    [1, 0, 0].

    [0, -1, 0],

    [-0.0, 640.346, 1]

    ]

    Text matrix = > array]

    [10.0, 0.0, 0].

    [0.0, 10.0, 0].

    [2062769.1732, 42.6732, 1]

    ] == You need to convert the text in user/device space space!

    TRM: Matrix]

    [1000.0, 0.0, 0.0],

    [- 10.0, 0.0, 0.0].

    [2062769.1732, 597.6728, 1.0]

    ]

    I can count the lines and calc a displacement of multipling that number by police in size (e.g. 12 pt), but how can I get the box of you text_object? If I have the box, I can make you whether he fits in a box...

    Please help with what I might hurt, or even better if you can help me to find the position of the text!

    They are NOT the starting point of the text box.   It is the basic position of the pen, taking the place of drawing the text.  The 'box' versus relies on measures of fonts - what you need to get the widths, leader, etc.  There's a picture of this in the ISO 32000-1 standard (section 9.2.4, I think).  In fact, the entire section text will make this clearer.

  • not ring or vibrate when a text message

    This problem started after I downloaded the 4.1.57 update yesterday.
    My phone is sound and I start noticing that my video audio text was no more. I checked to make sure if the same was for when people call me, and there was no problem there. My ringer turn off again no problem when I get a call, just no sound when a text/email is sent to me.
    And also my phone vibrates when I get a text as well. It starts to vibrate for a call and other applications, simply do not notify me when I receive a text.
    I tried to play with the settings and had no luck fixing it.

    Any ideas?

    Open the messaging app and select "menu" + "E-mail settings" and "SMS". There, ensure that there is a tick next to "vibrate". Hope this helps

  • Need help on why the text size continues to change as I'm typing or research. Need help on why the page disappears when I try to send email or when I try to view a page online.

    Can someone tell me how to fix these issues?  When I type a message by e-mail or through a Web site, I get the microscope & then the text size change automatically if small I can't read.  The other problem I have is that I continue to in getting kicked off the e-mail page or Web page without hitting any other buttons.  When I type an email, and more text size change, I get a message box asking me if I want to leave the page, click ok or if I want to stay on the page, click Cancel.  I always click Cancel, but get kicked off the e-mail page anyway and have to start over.  This happened to someone?   I asked Acer (my brand of windows 7 computer) for help, but they say the warranty that I treat these & have to pay.  I asked Microsoft to help on this, but I have to pay.  I got this Acer Aspire 7540 for about a month.  Cannot get help anywhere.  Anyone know what to do or where I can ask for help?

    Hi Phylomel,

    -Since when are you facing this problem?

    -Do you have yo umake any changes made to your computer before this problem started?

    -This only happens when you access email through Internet Explorer?

    -This happens on all the websites or any websites?

    However, you can try to optimize the settings of Internet Explorer on your computer and check if that helps you solve the problem. Access the link below and follow the steps to optimize Internet explorer.

    http://support.Microsoft.com/kb/936213

    Also, you can check if the CTRL key on the keyboard is sturck and if the program is based on shortcut keys.

    You try to use the on-screen keyboard and check if the problem persists.

    Steps to start the on-screen keyboard on:

    1. click on start.

    2. open the control panel (Classic view).

    3. click on ease of access Center.

    4. click on on-screen keyboard

    You can also try starting an online virus scan to check if your computer is infected and remove infected items and check if it helps you to solve the problem. Go to the link below to run an online virus scan.

    http://safety.live.com

    I hope this helps. Let us know the result.

    Thank you and best regards,

     

    Srinivas R

    Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

Maybe you are looking for

  • Print size is too small

    I have a HP C7250 all-in-one. I try to print to the Web and they come out to about 1/4 size. I searched through each dialog box, I find, on both the computer and printer and I cannot find any reason. Frustrating.

  • Problem Pen Tablet Portege M700

    Hello I saw a little problem with my toshiba so m700 I plug it into the docking station I can use the feather ok but if I want to remove it from the docking station and to write something in tablet mode after revocation the docker the pen stops worki

  • Equium A110-233 drive reads not not drives - error code 39

    Drive not reading all discs.Something to do with the driver. Far as I can tell it says error code 39.

  • HP m 9470, 9480 m, 820G 2: recovery of Windows 10 DVD

    I know that today ' hui when we buy HP laptop, they still come with win7 and win8.1 of the media. y at - it a way for us to download the windows media pro 10 operating system DVD and recovery for laptops mentioned above.

  • The digital camara con problemas.

    Tengo fotos in mi camara digital con su tarjeta memoria, luego connect the camara has the hago el protocolo para descargar pc photos to the pc. El problema esta aca, that spite than en camara tengo fotos, en the pc sale me como if fuera una vidéoconf