-
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
-
_root.gotoAndPlay(Math.round(Math.random()*20));