A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: parseInt not working pls help me in mx 2004

  1. #1
    Member
    Join Date
    Jan 2005
    Location
    Bangalore
    Posts
    93

    parseInt not working pls help me in mx 2004

    Hi everybody,

    pls help me i can't understand y parseInt is not working
    I'm having 1 array which contains the value from a user input, only numbers. when i supposed to sum all the values using parseInt i won't get result the result is only Nan. pls anybody have the solution for it.

    here is the code :
    (Note I'm Using Mx 2004 Professional)

    [I] input = "25,15,10,30,20";
    myArray = input.split(",");

    for (i =0; i<myArray.length;i++){
    val = (parseInt(myArray));
    sum += val;
    }
    trace(sum)


    the output only comes as Nan . pls help me

    Thanks in advance.

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    In MX 2004 you need to make sure the variable exists first. Just go
    Code:
    input = "25,15,10,30,20";
    myArray = input.split(",");
    sum = 0;
    for (var i=0; i<myArray.length; i++){
        val = parseInt(myArray[i]);
        sum += val;
    }
    trace(sum)

  3. #3
    Member
    Join Date
    Jan 2005
    Location
    Bangalore
    Posts
    93
    hi Chi,

    Ya It's working, thank U very much for Ur help.

    it's relay great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center