More control over Dynamic Classes?

I really like the fact that dynamic features are available in Flash, despite their slowness. :slight_smile:

With that said, is there any way to “auto detect” when a new property is being added to a dynamic class?

I’d like something along these lines:

public dynamic class Detector extends EventDispatcher
{
   public function Detector():void
   {
      this.addEventListener(PropertyEvent.PROPERTY_ADDED, onAdded);
      this.addEventListener(PropertyEvent.PROPERTY_REMOVED, onRemoved);
   }
   
   private function onAdded(ev:PropertyEvent):void
   {
      _numProperties++;
      trace("Property added:", ev.name, this[ev.name]);
   }

   private function onRemoved(ev:PropertyEvent):void
   {
      _numProperties--;
      trace("Property added:", ev.name, this[ev.name]);
   }

   private var _numProperties:int = 0;
   public function get numProperties():int
   { return _numProperties; }

}

It would be kindof difficult coding something like this from scratch unless you loop through each property to check if anything was added or removed each and every frame.

Has Adobe included anything like this? [SIZE=1](I’m going to predict… no, as usual)[/SIZE]