A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: string to integer

  1. #1
    Junior Member
    Join Date
    Jan 2004
    Location
    Florida
    Posts
    20

    string to integer

    I have the following readout from php
    &id=1&name=jshpro2&score=2&max=11&level=1&connecte d=2


    2

    which works perfectly from flash, loads the variables and all but as strings, score+=5 for example when score=1 returns 15 when it should be 6 etc... how do i take a string and treat it as an integer?
    -Jshpro2

    visit my website at www.onlycheaters.com

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Location
    Malibu
    Posts
    251
    Use the Number() function to convert the string to a number - as in score = Number(1) + 5;
    www.electricbluemonkey.com

  3. #3
    Junior Member
    Join Date
    Jan 2004
    Location
    Florida
    Posts
    20
    does not work for some reason
    -Jshpro2

    visit my website at www.onlycheaters.com

  4. #4
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    if your string starts with 0 it will be interpreted as an octal - then you'd want to use parseInt

  5. #5
    Junior Member
    Join Date
    Jan 2004
    Location
    Florida
    Posts
    20
    thanks
    -Jshpro2

    visit my website at www.onlycheaters.com

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