Custom Metadata Tags
Written by Venkat on December 27, 2007 – 11:38 pmA little known feature in Flex 3 is the ease with which you can define Custom Metadata. Custom metadata tags can be defined on a class and can be accessed at runtime. The compiler should be instructed to keep these metadata tags in FlexBuilder. This example shows you how to use custom tags to do logging on a class instance. I created a custom tag called ‘Log’ and added it to a class to log the click and mouseover events on the class. To include these tags at runtime, go to Project->Properties->Flex Compiler and add the following to your compiler arguments: -keep-as3-metadata+=Log. This will instruct the compiler to keep these custom tags. Remember to use += or all the current metadata tags like [Bindable], [Event] etc will be lost.
Basically, use describeType() method to get the class definition xml which contains the metadata information for the class. Parse this xml to get the list of events that we need to log. You can do some really cool stuff with this custom metadata tags. Take a look at the source to see how this is done. As usual, the source is well commented.
Subscribe to my blog using RSS