dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] random frame...

  1. #1
    Senior Member
    Join Date
    Mar 2006
    Posts
    139

    resolved [RESOLVED] random frame...

    hi,

    so this is my lovely code

    PHP Code:
    onClipEvent (enterFrame) {            
                
    _root.can_mc._x += 2.6;
                
                if(
    _root.can_mc._x >= 270)
                    {
    _root.can_mc._x =0;                
                
                
    _root.random_mc.gotoAndStop(random(9));        
                            
    }} 
    when my movieclip (can_mc) exceeds x position 270 it returns to x position 0 and plays a random frame from my movieclip random_mc.
    But what i want to know is how to get it to go to a random frame but not including frame 1, so it randomly chooses between frames 2,3,4,5,6,7,8,9.

    anyone know?

    thanks!

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,863
    PHP Code:
    random(8)+
    Then it will choose from 0 through 8, but add 1 to that number, making it go from 1 through 9
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Senior Member
    Join Date
    Mar 2006
    Posts
    139
    thanks!

    i tried but it still does it

    ive attached my fla that helps,

    thanks
    Attached Files Attached Files

  4. #4
    Senior Member
    Join Date
    Mar 2006
    Posts
    139
    oh wait,
    i fixed it, dont know why but for some reason
    PHP Code:
    random(8)+
    seems to work!

  5. #5
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,863
    oh, sorry >.<

    that was my fault, you wanted it to go from 2 to 9, not 1 to 9, loolz

    Your code is correct, and it's just that I'm not familiar with random (as there's another random function in Flash), but to explain why random(8)+2 works:

    random(8) will give you 0 through 7 (but not 8), and by adding 2 to that, you get 2 through 9
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  6. #6
    Member
    Join Date
    Feb 2012
    Location
    Nanggroe Aceh Darusalam
    Posts
    84
    Quote Originally Posted by Nig 13 View Post
    oh, sorry >.<

    that was my fault, you wanted it to go from 2 to 9, not 1 to 9, loolz

    Your code is correct, and it's just that I'm not familiar with random (as there's another random function in Flash), but to explain why random(8)+2 works:

    random(8) will give you 0 through 7 (but not 8), and by adding 2 to that, you get 2 through 9
    would you mind to tell me another random function in flash nig ?

    i want to make a random frame but the frame didn't return twice in the same frame

    i working on a quiz game, so it'll ridiculous if one question display twice
    maybe I'm old, but I want to learn more

Tags for this Thread

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