views:

24

answers:

0

I've created a class that parses an XML document to create an Object. I can successfully create dynamic, anonymous functions that return objects like this:

myObject[functionName]=function():Object { 
                         return {property1: value1, 
                                 property2: value2,
                                 propertyN: valueN} 
                       }

The above is "dynamic" I can add many name/value pairs to the return object. I need to be able to do a similar thing for other information in the XML document. I need to add additional statements to the anonymous function:

myObject[functionName]=function():void { 
                              this.property1 = value1;
                              this.property2 = value2;
                              this.propertyN = valueN;
                           }

I had the idea that I could create an array of anonymous functions with all the predictable property/value assignments that I could predict, but that isn't very flexible or robust. Does anyone have any ideas on how to add statements to an anonymous function like the way I constructed the anonymous function that returns an object?