A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: I want to change the number 1 in 0001

  1. #1
    Junior Member
    Join Date
    May 2005
    Location
    Cali - Colombia
    Posts
    2

    I want to change the number 1 in 0001

    I, guys...

    what do you think...

    I have to do a numeric randomizer that make a selection of one number between 5820 numbers...

    that's nice ... and NOT my problem...

    the problem is that I have to show it inthe folowing format:

    MyRandomicNumber = 12;
    MyNumberToShow= 0012;

    An d I have not a idea how to convert it...

    If (some guy, can help me){
    Im gonna be so gratefull with u;
    }

    K-Manto

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    A couple of IF's will do it....

    MyRandomicNumber = 12;

    if(MyRandomicNumber <10){
    MyNumberToShow= "000"+MyRandomicNumber ;
    }
    if(MyRandomicNumber >9 && MyRandomicNumber<100 ){
    MyNumberToShow= "00"+MyRandomicNumber ;
    }
    if(MyRandomicNumber >99 && MyRandomicNumber<1000 ){
    MyNumberToShow= "0"+MyRandomicNumber ;
    }
    if(MyRandomicNumber >999 ){
    MyNumberToShow= MyRandomicNumber ;
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    Junior Member
    Join Date
    May 2005
    Location
    Cali - Colombia
    Posts
    2
    Doo!!...
    I'm really a fool... it was so clear...


    thanks pellepiano

    any way... I really apreciate it..
    K-Manto

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