0 Replies Latest reply on Aug 8, 2012 3:57 AM by creak45

    How do I get autocompletion for Flex Metadata?


      I took a look at flex metadata and it seems to be quiet straight forward. Though I have a problem, I don't get autocompletion for the metadata.

      I'll tell you what I did, maybe you find an error. I want to create my own Style metadata tag named e.g. MyStyle. I want to create my own because it's easier for me to determine at runtime if the metadata was added by me or by the flex framework (therefore I will not use the predefined Style metadata tag).


      To add metadata is pretty simple, I just wrote this code to get it work:

      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
      width="1024" height="768">


      On my WindowedApplication component I added an added to stage listener to the stage. So all elements that are added to the application will fire that Event.ADDED when they are added to the stage. In that eventHandler I scan added elements for my metadata tag.

      protected function addedToStageListener(event:Event):void
      var classInfo:XML = describeType(event.target);
      for each (var x:XML in classInfo..metadata)
      if (x.@name == "MyStyle")

      I also added a flex-config.xml file (in the toplevel of my src folder) to add the compiler options, so that I can read my custom metadata tag on runtime. The file looks like this:

      <?xml version="1.0" encoding="UTF-8"?>

      When I run this, I get the result I expect

      <metadata name="MyStyle">
      <arg key="required" value="true"/>

      So this works. My next step was to add autocompletion when adding the metadata tag to the code. To do this you should create a metadata.xml which specifies the metadata tags right? So I did this and I ended up with this simple metadata.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <annotations version="2.1.1">
      <metadata name="MyStyle" description="Adds style.">
      <context name="class" />
      <attribute name="required" type="Boolean" required="true" />

      To add the metadata.xml correctly to the project I followed that tutorial by Adobe, but it doesn't work. I don't get autocompletion. Do you have any suggestions?


      Update: I use Flash Builder 4.6 Professional and I created a Flex Library Project.