Skip to main content
Inspiring
December 7, 2006
Question

Looping MovieClips

  • December 7, 2006
  • 3 replies
  • 224 views
I have three movie clips in my library. Each has a unique identifier (mc_1, mc_2, mc_3).

On my main timeline, I create an empty movie clip and want to attach the first MC from the library, have it play all the way through, the attach the second, have it play all the way through, etc...

Any suggestions on how to do this with actionscript?

Thanks
This topic has been closed for replies.

3 replies

jbresnerAuthor
Inspiring
December 8, 2006
Nevermind. Figured it out....

Make sure you have three movie clips in the library with linkage names of 'mc_1', 'mc_2', and mc_3'. Then add the actionscript below to frame 1 of the main timeline.


var mcArray:Array = new Array( 'mc_1', 'mc_2', 'mc_3' );
var nIndex:Number = 0;
function ShowNextClip() {
var mcClip:MovieClip = _root.attachMovie( mcArray[nIndex], 'showMe', 10 );

mcClip.onEnterFrame = function() {
if( mcClip._currentframe == mcClip._totalframes ) {
_root.ShowNextClip();
}

}

nIndex ++;
if( nIndex > mcArray.length -1 ) {
nIndex = 0;
}
}

ShowNextClip();
stop();
jbresnerAuthor
Inspiring
December 8, 2006
Well, here's the thing. I don't want to add any actionscript to the movie's in the library that are being dynamically loaded AND I am trying to keep all the actionscript on one frame. In fact, I only have one frame and one layer in my main timeline and that has all the actionscript.

any other suggestions?
Inspiring
December 7, 2006

add a counter at the end of the timeline (lastframe)

i++; or i=i+1;

and on the first frame

if (i==n) {
do_whatever ();
}

T.

> I have three movie clips in my library. Each has a unique identifier (mc_1,
> mc_2, mc_3).
>
> On my main timeline, I create an empty movie clip and want to attach the first
> MC from the library, have it play all the way through, the attach the second,
> have it play all the way through, etc...
>
> Any suggestions on how to do this with actionscript?
>
> Thanks
>