A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Start one one of 7 different frames

  1. #1
    Member
    Join Date
    Dec 2005
    Posts
    59

    Start one one of 7 different frames

    I used this in a previous movie and now it won't work:
    "
    random_start = (random(7))+1;

    if (random_start==1){
    gotoAndPlay(5);
    }
    else if (random_start==2){
    gotoAndPlay(10);
    }
    else if (random_start==3){
    gotoAndPlay(15);
    }
    else if (random_start==4){
    gotoAndPlay(20);
    }
    else if (random_start==5){
    gotoAndPlay(25);
    }
    else if (random_start==6){
    gotoAndPlay(30);
    }
    else if (random_start==7){
    gotoAndPlay(35);
    }
    "

    Basically I want the movie to start at one of the 7 points randomly each time. Any ideas where I'm going wrong?

    Thanks

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    random was deprecated since Flash Player 5.
    try using Math.random().
    PHP Code:
    random_start Math.round(Math.random()*7)+1
    or a different approach -
    PHP Code:
    stop();
    arr = [5,10,15,20,25,30,35]; // frame numbers
    arr.sort(function(){return Math.floor(Math.random()*3)-1}); // randomise the array
    frame arr[6]; // last element in arr
    gotoAndStop(frame); 

  3. #3
    Member
    Join Date
    Dec 2005
    Posts
    59
    Thank you!
    I adapted it to this:

    stop();
    arr = [2,30,60,90,120,150]; // frame numbers
    arr.sort(function(){return Math.floor(Math.random()*3)-1}); // randomise the array
    frame = arr[5]; // last element in arr
    gotoAndPlay(frame);

    But it never goes to frame 2. Is something wrong?

  4. #4
    Member
    Join Date
    Dec 2005
    Posts
    59
    So strange I did the whole thing form scratch with your code. - It's like some of my pictures make it go wrong - it goes to 35 every time. It worked at first, then when I imported pictures the randomiser stopped working. really odd.

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