Sunday, April 3, 2011

Is it possible to remove properties from a dynamic class?

I have a dynamic ActionScript Class that is used to send parameters to a WebService. Some of these parameters are always present, so they are public properties of the Class:

package
{
    [Bindable]
    public dynamic class WebServiceCriteria
    {
        public var property1:int;

        public var property2:String;

        public var property3:String;

        public var property4:String;
    }
}

But, I am also adding properties at runtime that can change over time:

criteria.runTimeProperty = "1";

I'm not very familiar with using dynamic classes, so I was wondering if it is possible to "remove" the new property. Let's say the next time I call the WebService I don't want that property sent - not even as a null. How can I remove it from the Class instance without creating a new instance each time?

From stackoverflow
  • I believe all you'd need to do is this:

    delete criteria.runTimeProperty;
    

    or

    delete criteria["runTimeProperty"];
    

    Either should do the same thing.

    See the delete documentation for specifics.

    Eric Belair : Thanks. Don't know how I missed that one!

0 comments:

Post a Comment