A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: playing random frames

  1. #1
    Senior Member
    Join Date
    May 2006
    Posts
    119

    playing random frames

    I'm trying to make make my quiz game play ramdom frames and not play the same frame twice.
    I found this on another forum but Im not sure how I can use it the way im doing things

    this is written on the first frame,
    -----------------------------------------------
    Code:
    [as:1:e3373511da]mc.onRelease = function()
    {
    this._parent.random_frame();
    }
    
    
    var frames = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ]
    function random_frame()
    {
    var c = frames.splice(random(frames.length), 1)
    mc.gotoAndStop(c)
    trace(frames.length)
    }
    [/as:1:e3373511da]
    My que to send the playhead to the next frame is at the end of an animation on the timeline.
    Would I just use write the array and splice var then call it at the end of my animation? like
    -------------------------------------------------
    on frame one
    -------------------------------------------------
    Code:
    var frames = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ];
    function random_frame();
    
    var c = frames.splice(random(frames.length), 1);
    -------------------------------------------------
    on my animation timeline que
    -------------------------------------------------
    Code:
    _root.gotoAndPlay(c);
    -------------------------------------------------

    am I on the right track?

    any help would be much appreciated.

    Mark

  2. #2
    Senior Member Branny's Avatar
    Join Date
    Feb 2001
    Location
    Manchester/UK
    Posts
    512
    _root.gotoAndPlay(Math.round(Math.random()*20));

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