2 Replies Latest reply on Oct 8, 2011 6:04 PM by Shongrunden

    New to Flex - Need Help with this Code

    Zachary40347 Level 1

      Untitled-1.jpg

      Getting NaN error... what am i doing wrong?

        • 1. Re: New to Flex - Need Help with this Code
          UbuntuPenguin Level 4

          What line are you getting the error at.  If you want to convert a string to a Number you generally have to use parseFloat( someString ).

          • 2. Re: New to Flex - Need Help with this Code
            Shongrunden Adobe Employee

            percent doesn't look like it is set to a value.  It will default to NaN and if you add anything to NaN you get NaN. 

            <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                           xmlns:s="library://ns.adobe.com/flex/spark"

                           creationComplete="init()">

                <fx:Script>

                    <![CDATA[

                        protected function init():void

                        {

                            var num1:Number = 5;

                            var num2:Number;

                           

                            var sum:Number = num1 + num2;

                           

                            trace(sum);

                        }

                    ]]>

                </fx:Script>

            </s:Application>

             

            You might want to initialize percent to zero.