Flash MX 2004.
timeline.layerCount
Read-only property; an integer that represents the number of layers in the specified timeline.
The following example uses the NumLayer variable to store the number of layers in the current scene:
var NumLayer = fl.getDocumentDOM().getTimeline().layerCount;