--- In flexcoders@yahoogroups.com, "per.olesen" <[EMAIL PROTECTED]> wrote: > > Hi, > > Basically, I would like to apply some (of my own) metadata to a > component instance inside the mxml. Like this: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> > <mx:ApplicationControlBar> > > <mx:Metadata>[MyMetadata]</mx:Metadata> > <mx:Button id="foo" label="Blah"/> > > </mx:ApplicationControlBar> > </mx:Application> > > And then only have the [MyMetadata] applied to the foo button > instance. Is this possible? Placing it there makes the compiler bark. > I guess this is due to the fact, that mxmlc will put it before a class > definition. > > I then tried something like this: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> > <mx:ApplicationControlBar> > > <mx:Script>[MyMetadata]</mx:Script> > <mx:Button id="foo" label="Blah"/> > > </mx:ApplicationControlBar> > </mx:Application> > > but this made the compiler bark too :-) about metadata requiring an > associated definition. And of course it is right. My guess is the > mxmlc compiler is translating the above to something like: > > acb = new ApplicationControlBar(); > [MyMetadata] > b = new Button(); > acb.add(b); > > and of course then it is wrong with the metadata element there. Am I > right? > > Can I do it some other way? > > I came up with this: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> > <mx:ApplicationControlBar> > > <myns:MetadataButton id="foo" label="Blah"/> > > </mx:ApplicationControlBar> > </mx:Application> > > and then have a component MetadataButton.mxml with this content: > > <?xml version="1.0" ?> > <mx:Button xmlns:mx="http://www.adobe.com/2006/mxml"> > <mx:Metadata>[MyMetadata]</mx:Metadata> > </mx:Button> > > which works! But the MyMetadata annotation will change on the various > buttons. So I would like to inline it, like this: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> > <mx:ApplicationControlBar> > > <mx:Button xmlns:mx="http://www.adobe.com/2006/mxml"> > <mx:Metadata>[MyMetadata]</mx:Metadata> > </mx:Button> > > </mx:ApplicationControlBar> > </mx:Application> > > but this makes the compiler bark again. > > Any help? >
Hi Per, You can tell the compiler to accept custom metadata tags by using the "keep-as3-metadata" compiler flag. You'll have to add it to your compiler options. See http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_14.html for details. I hope that helps. -- david keutgens software consultant cynergy australia web | http://www.cynergysystems.com