A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Generating Random number series

  1. #1
    Member
    Join Date
    Nov 2008
    Posts
    49

    [F8] Generating Random number series

    Hello Friends,


    I need to make a random number series something like " LK208T38". I can make single random number but dont know how to produce a series. May be we can store the characters in array and display them. Please suggest.

    I am trying to do it in AS2.


    Regards,

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    you can do something like:

    Code:
    getRandomSeries();
    
    
    function getRandomSeries():Void
    {
    	var randomSeries:String = getLetter() + getLetter() + random(10) + random(10) + random(10) + getLetter() + random(10) + random(10);
    	trace(randomSeries);
    
    }
    
    function getLetter():String
    {
    	return String.fromCharCode(Math.floor(Math.random() * (91 - 65) + 65));
    }
    I've added up random(10)' s separately because wasnt sure whether you wanted leading zeros or not.. the above will give you leading zeros..
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Member
    Join Date
    Nov 2008
    Posts
    49
    Hello Broh,

    Its awesome. Working perfectly OK, exactly how I needed it. Thanks alot

    Have a nice day.

    Regards,

  4. #4
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    you're welcome..glad i could help!!
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

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