This content has been marked as final. Show 7 replies
Hi, sorry to bump my own thread but I'm pulling my hair out with this. As it's not working I have attached my latest attempt.
Any help I'd be so grateful.
I have four layers all on the first frame, one actionscript layer the other three contain a movieclip each. Could this be the problem?
Should each movie clip have its own frame?
You don't say exactly what isn't working about your example. From how it looks it seems like it should, so exactly what is the problem?
No, each clip doesn't need to have its own frame. Most often my files only have one frame on the main timeline and then everything else is controlled from there.
Generally I would have a stop() on the first frame of each of those clips. Then I wouldn't have to worry about stopping some and playing one. If they all are stopped by default you only have to tell the one that you want to play.
Below is the code I use to shuffle an array. Just put this code on a frame somewhere before you need to have your array randomized. (I usually just put it on Frame 1.)
Then after you have created your clips array you can shuffle it with.
The array will now be a random order. So you can just pull out the elements one at a time to play.
I'm not sure if that helps because I'm not really sure what is wrong. Post back with more details.
Thank you for replying.
I will further explain my woes.
As I have said I have four layers each on the first frame, three have a movieclip each on. The fourth is a actionscript layer. All my actionscript is on this layer, I have a stop(); at the end of each of my movieclips.
As I have said I want a different movieclip to appear every time the SWF is loaded, and after one movieclip has played I would like another random movieclip to be played, etc.. I want it to be and ongoing process.
The problem is that when I currently load my SWF it's just the movieclip on the top layer which is played each time.
I have tried the actionscript you have suggested, thank you by the way. I placed it in the actionscript layer, however unfortunately this didn't work.
Any further help you or someone else could provide would be greatly appreciated.
So what happens if you have only this code on your first frame?
Hi, thanks for responding.
I place the code you gave me on the first frame of the actionscript layer.
The output was shown as:
The clips: Paul_mc,Gary_mc,Ama_mc
The clips: Paul_mc,Ama_mc,Gary_mc
However when the SWF was loaded it still showed the movieclip on the top layer which is Paul_mc.
Thank you for your help so far.
Okay, so the shuffling is working. We haven't done anything about visibility or playing. Next you should make all of the clips invisible and stop them.
Finally we can do something about playing the clips.
Of course your going to need something that checks to see when the clip is done playing. The easiest perhaps would be to put a
on the last keyframe of each of your clips.