dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: random start problem.

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    2

    random start problem.

    I have a movie clip that i would like to start at a random frame.
    Everytime i load the file, i would like it to start at 1 of 10 frames, either at frame (30,200,370,540,710,880,1050,1220,1390,1560), i just want it to continue after but the first starting frame must be random on one of those frame numbers...maybe an onEnterFrame command??

    Any help is very grateful!

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    assuming your movieclip has instance name mc:

    Code:
    var aStartFrame:Array = [30,200,370,540,710,880,1050,1220,1390,1560];
    mc.gotoAndPlay(aStartFrame[random(aStartFrame.length)]);
    Last edited by silentweed; 06-15-2007 at 10:22 AM.
    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
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Code:
    // code on frame#1 of movie
    
    arr = [30,200,370,540,710,880,1050,1220,1390,1560];
    trace(arr);
    
    arr.sort(function(){return Math.floor(Math.random()*3)-1});
    trace(arr);
    
    frame = arr.pop();
    trace(frame);
    
    gotoAndStop(frame);
    hth

  4. #4
    Junior Member
    Join Date
    Jun 2007
    Posts
    2
    thank you so much for the help!
    i got it working!

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    on behalf of silentweed and myself -
    you're welcome

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