How do I get autocompletion for Flex Metadata?
i took @ flex metadata , seems quiet straight forward. though have problem, don't autocompletion metadata.
i'll tell did, maybe find error. want create own style metadata tag named e.g. mystyle. want create own because it's easier me determine @ runtime if metadata added me or flex framework (therefore not use predefined style metadata tag).
to add metadata pretty simple, wrote code work:
<s:group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
width="1024" height="768">
<fx:metadata>
[mystyle(required="true")]
</fx:metadata>
</s:group>
on windowedapplication component added added stage listener stage. elements added application fire event.added when added stage. in eventhandler scan added elements 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")
trace(x);
}
}
i added flex-config.xml file (in toplevel of src folder) add compiler options, can read custom metadata tag on runtime. file looks this:
<?xml version="1.0" encoding="utf-8"?>
<flex-config>
<compiler>
<keep-as3-metadata>
<name>mystyle</name>
</keep-as3-metadata>
</compiler>
</flex-config>
when run this, result expect
<metadata name="mystyle">
<arg key="required" value="true"/>
</metadata>
so works. next step add autocompletion when adding metadata tag code. should create metadata.xml specifies metadata tags right? did , ended 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" />
</metadata>
</annotations>
to add metadata.xml correctly project followed that tutorial adobe, doesn't work. don't autocompletion. have suggestions?
update: use flash builder 4.6 professional , created flex library project.
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment