A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: random frame

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

    random frame

    Im wonder how I can make

    _root.nextFrame();

    go to a random frame and not play the same frame twice?

    would this be the job of an array? write all the frame labels into an array and pop them when you go to the next frame?

    thanks

    Mark

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    119
    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,
    -----------------------------------------------
    [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
    -------------------------------------------------
    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
    -------------------------------------------------
    _root.gotoAndPlay(c);
    -------------------------------------------------

    am I on the right track?

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