Custom metadata in AS3/Flex?

后端 未结 2 945
暗喜
暗喜 2021-01-17 13:53

How to create and to work with custom metadata in ActionScript3/Flex?

2条回答
  •  梦谈多话
    2021-01-17 14:40

    To create metadata, just use square bracket syntax in your class definition:

    [ClassAttr]
    public class ClassWithMetadata {
        [AttributeNoArgs]
        public var data:Object;
    
        [AttributeWithArgs(arg="value)]
        public var prop:Object;
    }
    

    Call describeType(ClassWithMetadata) to get xml description of your class. Metadata will be there, you can parse it and process as you like.
    To prevent compiler from stripping your metadata, add compiler argument -keep-as3-metadata Attribute for each attribute name you using. This can be done in library settings or in each project that uses metadata.

提交回复
热议问题