Skip to main content
AndrewYuCWA1987
Known Participant
June 27, 2011
Question

totalFrames of a MovieClip

  • June 27, 2011
  • 1 reply
  • 6137 views

Hi, everyone.

Recently I got trouble with totalFrames attribute of MovieClip object, this is the case: in Flash CS, I created two movieclips, one has say 10 frames animation, another one, I drag the first MC in to it, then the second MC has only one frame in it's own time line, right? Then I export them as SWC file to include them in my project. Here's the problem, when I'm trying to get total frame number of these to MC like below, I just get to actual number of frames in the second MC:

     trace( new FirstMC().totalFrames );     //10 frames in the first MC

     trace( new SecondMC().totalFrames );     //1

So my question is, is there any way to get the actual number of frame for those MovieClip resource like the second one, without visiting any sub-movieclips in it, Thank you for any sugestions.

This topic has been closed for replies.

1 reply

relaxatraja
Inspiring
June 27, 2011

I drag the first MC in to it, then the second MC has only one frame in it's own time line, right?  Yes

  trace( new FirstMC().totalFrames );     //10 frames in the first MC

  trace( new SecondMC().totalFrames );     //1

Yeah! yes you have only one frame right.

SecondMC.FirstMC.totalFrames will give you the dragged mc totalframes.

AndrewYuCWA1987
Known Participant
June 27, 2011

Thank you, I cant agree more.

But my biggest problem is, there're multiple sub-movieclips within the target MC, and all of them have different frame numbers and I dont know how many, neither can I control it, it's not FIXED. All I got is one movie clip and I want to know the exact number of frames it has, Maybe I can insert code into the very last frame of the longest sub-movieclip, like "dispatchEvent(new Event("last frame!"));" then listener to this event, when I get the event trigered, I know it's frame count. I dont think it's the best way, I'm using a xml file to store that value for now, right, open CS, count how many frames the MovieClip has, and write it in the xml. And I am not happy with it

The reason why I'm doing this is that I'm building up a Avatar system myself with AS3, all parts like arms and hair are seperated MCs. Any sugestion on "Avater System" for flash will be very welcome.

relaxatraja
Inspiring
June 27, 2011

Then loop thru the main movieclip with nested one:

for(var i=0; i<mcContainer.numChildren-1; i++) { 
var mc:MovieClip = MovieClip(mcContainer.getChildAt(i));
trace(mc.name);
trace(mc.totalframes);
mc.doStuff(); }