• Home
  • About
  • Books
  • Canvas

ravigeek

Experience | Our source of knowledge
Stay updated via RSS

  • rs.sharma@live.com

  • Geekwitter

    • A man who doesn't spend time with his family can never be a real man... 2 months ago
    • Happiness is not something you postpone for future... It is something you design for the present... 3 months ago
    • Too many people spend money they haven't earned, to buy things they don't want, to impress people they don't like... ~Will Smith 3 months ago
    • I enjoyed Big Boss show, where house members are fighting for house leader position with one motive “Fame”… 9 months ago
    • Moody's cuts Japan's credit rating to Aa3 from Aa2... Who's next? lnkd.in/kQpzw6 9 months ago
    Follow @ravinxg
  • Blog Diary

    July 2011
    M T W T F S S
    « Jun   Aug »
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • Blog Stats

    • 7,578 hits
  • Enter your email address to follow this blog and receive notifications of new posts by email.

    Join 8 other followers

  • Category

    Adobe API Apple Best Practice Flex Health and wellness HTML5 Innovation LCDS Media Mobile RIA SDLC Spring Technology Thoughts
  • Tags

    Actionscript3 Adobe AIR Apache Apple AR AS3 Augmented Reality Best Practice Big Blue collections data provider Enterprise Application Estimation FHTML Flash Player Flex FluidHTML Framework Google HTML5 IBM IList Innovation JavaFx LCDS MDD Media Mobile OSMF RIA SDLC Simulation Social Media Spark USB Video Virtual Reality WAC web1.0 web2.0 web3.0 web semantics www XMLList
  • Archives

    • April 2012 (1)
    • March 2012 (1)
    • February 2012 (1)
    • January 2012 (1)
    • December 2011 (1)
    • November 2011 (1)
    • October 2011 (2)
    • September 2011 (3)
    • August 2011 (3)
    • July 2011 (4)
    • June 2011 (5)
    • May 2011 (2)
    • April 2011 (2)
    • March 2011 (3)
    • January 2011 (1)
    • September 2010 (3)
    • August 2010 (7)
    • August 2008 (1)
    • July 2008 (2)
    • June 2008 (8)
    • May 2008 (1)

Digging into Custom Metadata Tag in Flex and ActionScript

Posted: July 10, 2011 in Adobe, Flex, Technology
Tags: Actionscript3, Flex, Metadata, Reflection
0

The basic lineaments of Flex are tag based programming and use of metadata injection. Several times we used metadata tags in our Flex application and most of us are very familiar with Flex SDK defined metadata i.e. [Bindable], [Event], [Effect] and many more. All these are assigned and SDK defined metadata tags, apart from this we can defined our own metadata tags also. User defined metadata called custom metadata. Basically metadata tags provide information to the Flex compiler that describes how your components are used in a Flex application.Custom metadata tag will be accessed at runtime by FlashPlayer. Nowadays for injecting the dependency many engineer’s introduced this in the application framework. Like in Swiz framework has a [Autowire] custom metadata tag. Autowire metadata is used to define the bean name and is injected with the object that is configured in SwizBeans.xml with the ID field.

This custom metadata feature give us an option to introduced our own tag for achieving specific purpose. For this we have to instruct the compiler to keep this keyword as metadata. If you open the flex-config.xml then you can find the list of sdk defined metadata in <keep-as3-metadata>. For creating own custom metadata we have to use the same -keep-as3-metadata argument in Flex compiler for providing the name of custom metadata tags.

Create Custom metadata in three simple steps.

Steps 1 – in the compiler options you need to tell the compiler to keep your new metadata tag, using this -keep-as3-metadata+=MyMetaData. Be sure to use the “+=” otherwise you lose the standard Flex metadata tags.

Steps 2 – Add your new tag into your AS3/MXML files. Depending on how you intend to use your metadata tag, you may just have the tag, like this [MyMetaData] or with some attributes like this [MyMetaData(value="my custom tag")], it’s all depends on how we want to use it.

Steps 3 – Now we need to create a custom metadata tag manager class for handling this metadata logic. In custom metadata tag manager class we need to use the flash.utils.describeType to find the properties annotated. The describeType util returns a XML object describing the public properties/methods on the specified class.

Here in the below example you can easily understand the process of creating custom metadata.

How to create custom metadata tag

From the metadata XML object we have to extract the custom <metadata> value and using those value we need to write our own metadata manager class for providing business logic.

Here I want to give an useful tips regarding compiler argument. If we are using Flex SDK version 3.5 and below then we have to provide the metadata name using  -keep-as3-metadata+=MyMetaData. In the case of Flex SDK version 4.0 and above we don’t need to provide the metadata name in compiler argument. Please keep in mind that this is the enhancement in Flex SDK 4.0 and above.

For getting into the live and real example of custom metadata tag you can browse Christophe Coenraets on creating and using metadata tags. He created an AIR app that accesses a SQLLite database. Instead of manually mapping out the relationships between value objects and tables and the necessary queries he used the metadata tags to annotate value object properties with their corresponding database table columns.

Share this:

  • Share
  • Facebook
  • Twitter
  • LinkedIn
  • Print
  • Email

Like this:

Like
Be the first to like this post.

Leave a Reply Cancel reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. ( Log Out / Change )

Twitter picture

You are commenting using your Twitter account. ( Log Out / Change )

Facebook photo

You are commenting using your Facebook account. ( Log Out / Change )

Cancel

Connecting to %s

A closer look of mx_internal namespace
Become A Brand Ambassador Of Yourself

  • Top Clicks

    • grepcode.com
    • ravigeek.files.wordpress.…
    • ravigeek.files.wordpress.…
  • Top Posts & Pages

    • Adobe Muse : Build stylish website without writing code
    • Flex Past, Present and Future - Adobe’s View
    • Spring + BlazeDS Integration API for Flex based Enterprise Apps
    • Significance of Vector and [ArrayElementType] type metadata
    • Adobe Flash Player and its future
    • Adobe AIR 3 – Network detection using NetworkInfo native extension
    • AS3 Tips – Uses of rarely used operator
    • In search of Me
  • Top Rated Post

Blog at WordPress.com. | Theme: Greyzed by The Forge Web Creations.
Follow

Get every new post delivered to your Inbox.

Powered by WordPress.com
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.