Random MovieClip load in another MovieClip, with its own functions

I searched, but couldn’t find the right answer on my question.

What I want to do is as followed:

I’ve got 12 MovieClips, which all have specific functions in the movie. Those MC’s will appear and dissappear after a few seconds. But what I want is, that those MC’s have to appear at random .

If all 12 MC’s have appeared, the appearance has to be stopped. So for example MovieClip number 4 has to appear just once. So 12 MC’s will appear, but everytime when the movie starts, the appearance has an other sequence.

What is written above I want to place in an other MC. So there is one MC which ‘load’ 12 MC’s within it… at random that is.

Please help me out with this!

Kudos for searching first :beam:

Im not Entirely sure what you’re after, but Im pretty sure your solution will involve using arrays. Ill assume you are attaching your clips with attachMovie ? If so then what youd need to do is keep all your 12 linker IDs in an array like so

clips = [“MC1”, “MC2”, “MC3” … “MC12”]

then whenever you need to get a random MC out of that array, use

randMC = clips.splice(random(clips.length),1);

what this does is uses splice to extract (and completely remove) one of the ID names out of the array based on a random number generated from the arrays length. Because we are using the arrays length, you will always be able to get a random element no matter how big that array is. This is important because each time you use splice here, we are taking out and element and making it shorter than it already was.

Now all you need to do is make sure there are elements in the array before you can take anything out. That is done simply by saying

if (clips.length){
randMC = clips.splice(random(clips.length),1);

once clips has no more IDs in it, it will have a length of 0 and the if will resolve to false meaning that line wont be run any further. If you want you can put an else to know when this happens.

If not THE solution, maybe it will at least put you on the right track

Thank you verry much!
This is exactly what I’m trying to do and wanted to know. Tnx again!