Reputation: 1006
I have a little problem with counting all elements on stage. Flash, unfortunately is counting all objects on the stage without drawn objects (all shapes, including drawing objects, rectangles etc) all missed. Is there any way to count them?
Thanks in advance.
Upvotes: 0
Views: 238
Reputation: 1
I am sure this is how I found the number of leaves in the tree(in my project).
Upvotes: 0
Reputation: 22604
If you are referring to drawing primitives, such as lines and circles, then no, there is no way. You can only address and modify the container (Shape, Sprite, MovieClip, etc.), but once a primitive vector element is drawn, you lose any reference to it. You can only modify bitmap data.
You could, however create your own class and keep a counter for all those elements that the Flash Player doesn't recognize - just increase the count whenever something is drawn and reset on Graphics.clear()
.
Upvotes: 2
Reputation: 11600
As far as I know there is no such thing as graphics.numChildren
like there is with MovieClip, see docs.
The closests alternative would be to manually keep track of the number of items drawn whenever you draw them either via array/vector or a simple incremental integer.
Upvotes: 1