A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Maybe a dumb question..

  1. #1
    Junior Member
    Join Date
    Sep 2004
    Posts
    23

    Maybe a dumb question..

    but...

    does neone know how to change a variable into a number?

    such as

    Code:
    String = "23";
    Number = function ??(String);
    Number = 23;
    Thank you.

  2. #2
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    Either use new Number() or parseInt():
    code:

    str = "23";
    num = new Number(str); // convert to any number, including floating points


    or
    code:

    str = "23";
    num = parseInt(str); // only works if the number is an integer (there is a parseFloat() as well)


  3. #3
    Junior Member
    Join Date
    Sep 2004
    Posts
    23
    ^Thanks, that got my code working now

  4. #4
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    Can't you just use
    code:

    str = "21212";
    number = int(str);


    or is it old syntax?

  5. #5
    Senior Member Danskeren's Avatar
    Join Date
    Jan 2004
    Posts
    263
    In flash you can simply just write:

    String = "23"
    Number = String
    Possibilities are only limited by the lack of creativity...
    www.Ryer.dk
    www.ArrayPainter.com
    www.PawnStar.net

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