I have a class marked Bindable with many properties.  The class has a
read-only function which returns come custom XML based on the
properties.  I want to fire a bindable event when any of the properties
change.

So far the ways that I've thought of doing it are:
1) Create a ChangeWatcher that monitors each individual property.  (The
host would be "this" and the chain would be an array with every single
property listed in it.)
2) Write a setter and a getter for every single property, with the
setter dispatching a custom bindable event.

The problem with the first method is I'd have to list out every
property.  Every time a property was added to this class I'd have to
make sure I updated the chain array.  The problem with the second method
is I'd have to write setters and getters for every single property. 
(The actual class has more than 20 properties.)  It would make the class
harder to read.

Is there a way I could watch the properties for change with just a
couple lines of code?


     [Bindable]
     public class TheProperties
     {
         public var presetName:String="default";
         public var presetThumb:String="";
         public var presentationTitle:String="";
         public var presentationThumb:String="";
         public var presentationLogoURL:String="";
         // many more properties...

         [Bindable(event="propertyChangeEvent")] // necessary to get rid
of binding warnings
         public function get xmlCode():XML {
             // some funky stuff to create XML based on above properties
         }
     }




Reply via email to