简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM