How to find all objects of a type on the stage

actionscript-3

I'm trying to iterate through all the objects in the stage and I'm not sure how to do it.
It's kind of improvised through my previous experience with C# and javascript.

  1. First I need the correct list/array with all the stages children.
  2. I need to check their type. I have a special custom class which extends Sprite with some additional properties only.

Someone proficient in actionscript 3.0 who can show the proper way to do?

for(var obj:DisplayObject in DisplayObjectContainer) {
    if(typeof obj == "Pic") {

Best Answer

The easiest would be to use the "is" operator to accertain the object's class.

An example:

for( var i:int = stage.numChildren - 1; i>=0; i-- ) {
    if( stage.getChildAt(i) is Pic ) {
        // Do stuff with members of Pic class
Related Topic