7 Replies Latest reply on Nov 15, 2007 7:54 AM by kglad

    AS3: DisplayList and EventListeners

    "B"
      I was wondering if there's a way to monitor the DisplayList so that you can see when items get removed/Garbage Collected.

      And is there a way to monitor EventListeners so that you can see if you're effectively removing them when they're no longer needed?

      Thanks...
      Brenda
        • 1. Re: AS3: DisplayList and EventListeners
          "B" Level 1
          I'm not sure if it's considered rude to bump a message so please forgive if I've done something that's considered bad forum etiquette.

          Any replies to my original message would be well appreciated. Thanks!!
          • 2. Re: AS3: DisplayList and EventListeners
            kglad Adobe Community Professional & MVP
            you can monitor the display list but that doesn't make much sense in the present context: if you want something gc'd, it must be removed from the displaylist. you surely won't detect something being gc'd by monitoring the displaylist.

            in general, you must know to what displayobjectcontainer you added your display object or you can't remove it. and if you know that, you must use removeChild() or removeChildAt() to remove it.

            you could check the numChildren property of your displayobjectcontainer, but that would be a pretty crude way to determine if a particular object has been removed from that displayobjectcontainer.
            • 3. Re: AS3: DisplayList and EventListeners
              "B" Level 1
              For anyone who is curious on seeing what is being added and removed from the display list, here is the code:

              • 4. Re: AS3: DisplayList and EventListeners
                kglad Adobe Community Professional & MVP
                that won't trace the display list. it only traces the objects attached to the stage, empty and myLoader which is very specific to your application.

                the following function will trace the names of all objects in the display list:

                • 5. Re: AS3: DisplayList and EventListeners
                  joeflashTO Level 1
                  Unfortunately there is no way to monitor the garbage collector, which is the only sure fire way to determine whether something has been GC'ed. Rumour has it this may be introduced in the Flash 10 player, but it's just a wish list entry for now; one can only hope.
                  • 6. Re: AS3: DisplayList and EventListeners
                    "B" Level 1
                    Silly me. And here I thought I was so smart figuring it out. Oh well... you are way better at this than me kglad!! Thank goodness for people like you who set people like me straight.

                    I'll mark yours as the answer... and at some point I'll get around to testing it. But I'm done for the night (1:30am yikes!!) so testing will have to wait!!

                    Thanks for the code!! You're great!!

                    And thank you Joe for your reply.

                    Brenda
                    • 7. Re: AS3: DisplayList and EventListeners
                      kglad Adobe Community Professional & MVP
                      you're welcome.

                      (and hey, if you solved your problem, you deserve some rest.)