mswiszcz
mswiszcz

Reputation: 1006

Counting all 'drawing objects' on stage

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

Answers (3)

Gilli
Gilli

Reputation: 1

  1. Copy all the objects(Mc's, Graphics's...etc.)
  2. Make a new file.
  3. Paste the object into the stage
  4. Right click and select....Distributes to layers.
  5. Check the number of the layers displayed.

I am sure this is how I found the number of leaves in the tree(in my project).

Upvotes: 0

weltraumpirat
weltraumpirat

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

ToddBFisher
ToddBFisher

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

Related Questions