# How to count how many frames are there in a MovieClip?

**URL:** <https://forum.kirupa.com/t/how-to-count-how-many-frames-are-there-in-a-movieclip/232115>\
**Category:** flash\
**Created:** [July 11, 2007, 10:40am UTC](https://forum.kirupa.com/t/how-to-count-how-many-frames-are-there-in-a-movieclip/232115 "2007-07-11T10:40:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonp](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@anonp](https://forum.kirupa.com/u/anonp)\
**Post date:** [July 11, 2007, 10:40am UTC](https://forum.kirupa.com/t/how-to-count-how-many-frames-are-there-in-a-movieclip/232115/1 "2007-07-11T10:40:18Z")

</div>

Hi,

Assume I have a SWF file with the following structure -

On the main timeline:  
Movieclip A appears on stage and begins in frame 1. It stops in frame 100 and goes away.  
Movieclip B appears on stage and begins in frame 20. It stops in frame 200 and goes away.

Inside Movieclip B timeline:  
Movieclip C appears and begins in frame 40. It stops in frame 400 and goes away.

I want the following function

function getNumFrames(aSWFClip:MovieClip):int

Originally, I thought I can just iterate through each child with getChildAt() and count how many frames each one requires. However, because not all the children get added immediately to the main timeline, getChildAt() does not always return ‘ALL’ children.

What should I do?

Thanks! 🙂
