A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Pls help! - How to make random numbers??

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    16

    Pls help! - How to make random numbers??

    Hi,

    I need to make a random number (from 2-4) that will change every time when i'm starting the swf file.
    I don't know how to write it on AS 2.

    Thanks for the help!!

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Try
    PHP Code:
    Random Math.floor(Math.random() * 3) + 2;
    trace(Random); 
    perhaps on the first frame of your file.

    It may show the same number several times repetitively.

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    16
    Hi,
    I need it to be on the screen as a text.
    It is possible?

    Thanks for the help!




    Quote Originally Posted by fruitbeard View Post
    Hi,

    Try
    PHP Code:
    Random Math.floor(Math.random() * 3) + 2;
    trace(Random); 
    perhaps on the first frame of your file.

    It may show the same number several times repetitively.

  4. #4
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    Quote Originally Posted by benh1510 View Post
    Hi,
    I need it to be on the screen as a text.
    It is possible?
    Yes, it is possible
    who is this? a word of friendly advice: FFS stop using AS2

  5. #5
    Junior Member
    Join Date
    Jul 2013
    Posts
    16
    Can you please write it?
    i don't know how to write in AS2

    Thanks again.

    Quote Originally Posted by realMakc View Post

  6. #6
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    Can you please click the link? Here it is again, in case it was not obvious it even was there: http://help.adobe.com/en_US/AS2LCR/F...=00000265.html
    who is this? a word of friendly advice: FFS stop using AS2

  7. #7
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    here is a slightly longer way to do what you require, but it will give you some idea on how to do it how you want.
    PHP Code:
    rindleParpSicordTheText Math.floor(Math.random() * 3) + 2;
    if (
    rindleParpSicordTheText != 5)
    {
        
    myTextonTheScreenBig.text rindleParpSicordTheText;


  8. #8
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    rindleParpSicord
    Is this a riddle?
    who is this? a word of friendly advice: FFS stop using AS2

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