In my movie I have a movie clip that I want to circulate between a random selection of 12 frames automatically. Basically I want the movie clip to load like this.
Frame 3
Frame 5
Frame 2
Frame 3
Frame 10
…
I don’t mean exactly this order, I just want it to cycle randomly through the 12 frames. How should I go about doing this?
wel you could just use the Math.Random with like Math.Floor the help files have usage and then just put something like
onEnterFrame = function(){
gotoAndPlay(randframe);
}
sorry if im not clear enough there for ya but just check the help files for falsh and they should have the random functions and how to use them explained there and i believe the goto and play ought to work for ya havnt tested it but thats my best idea. and remember you could always just put the random function into say like a mnouse move or on key down whatever you like.

I think I got what you’re saying, though I’m still getting an error. What I’ve done is made a new layer of blank frames and put this code in the frame.
var Frame=Math.ceil(Math.random()*12);
onEnterFrame = function(){
gotoAndPlay(Frame);
};
I did some looking around online and thought that the Math.ceil would do better than Math.floor for what I’m doing since I’d need a number from 1-12 rather than 0-11. However, when I run the movie I get an error on Line 2.
Access of undefined property onEnterFrame
Anyone know what’s up with this?
Looks like an AS3 error in which case this isn’t the right forum. I suspect it’s trying to trigger the onEnterFrame before the MC has been fully loaded and so the random frame doesn’t actually exist.
And that’s merely the start of your problems. From what I understand, you don’t actually want to play individual random frames but you actually want to play them all in a random order. That means you’ll have to store the random frame order and so Arrays are probably the best bet.
However, looping through the shuffled array using a for loop won’t be any use as the code will always execute far faster than Flash can render each frame of your randomMC. This means you will need to introduce some kind of delay using setInterval.
I’ve had a play and come up with the following approach:
// Create an array containing the frame numbers
var myArray = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
// Create another array containing the shuffled contents of myArray
myShuffledArray = myArray.sort(function () {
return Math.round(Math.random());
});
// Check that shuffle worked
trace(myShuffledArray);
// Assign a start value to loop through myShuffledArray
var i = 0
// Assign an end value to loop through myShuffledArray
var j = myShuffledArray.length
// Function to play frames according to myShuffledArray order
function playShuffled() {
trace (myShuffledArray*); // Check that correct frame number is returned
randomMC.gotoAndStop(myShuffledArray*+1); // Add 1 because the first frame is blank
i++; // Increment the counter
if (i == j){ // Check if end of the shuffled array has been reached
clearInterval(intervalId); // and clear the interval
// add other code here to remove randomMC or
// delete the clearInterval and reset the value of i to 0
// if you want to continually repeat randomMC
}
};
// Use an Interval to create a pause between frames
// Assign delay value in milliseconds and adjust as required
// If you don't want a delay, use 0
var delay = 5000;
intervalId = setInterval(this, "playShuffled", delay);
This assumes that you have a movieclip on the stage with an instance name of randomMC. This clip should contain 13 frames; the first should be blank to prevent anything being seen followed by the contents of your next 12 frames. It should also have a stop(); action in the first frame.
This can, of course, be adapted to play anything in a random sequence…images, graphics, other MCs within randomMC’s timeline. You can even randomise an animated tween.