When creating Flex components, all child components (buttons, combobox, etc..) you add are always publicly accessible. There is a way to hide this and this is by using the Metadata tag "Exclude"
Here is a common Flex Component Example:
-
<?xml version="1.0" encoding="utf-8"?>
-
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
-
<mx:Button x="167.5" y="146" label="Click Me" id="btn"/>
-
</mx:Canvas>
In the example above, "btn" property is publicly accessible outside that component. For you to hide it, you must add an "Exclude" metadata tag.
Here's is an example:
-
<?xml version="1.0" encoding="utf-8"?>
-
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
-
<mx:Metadata>
-
[Exclude(name="btn", kind="property")]
-
</mx:Metadata>
-
<mx:Button x="167.5" y="146" label="Button" id="btn"/>
-
</mx:Canvas>
Now, the "btn" property won't be accessible outside that component. will still be accessible but it won't show up in the code hinting. Thanks to Sid Maskit for pointing this out.
Sid Maskit provided ways on how to do this not using the [Exclude] metadata/
Other Exclude kinds are
[Exclude(name="direction", kind="property")]
[Exclude(name="setFocus", kind="method")]
[Exclude(name="focusIn", kind="event")]
[Exclude(name="horizontalGap", kind="style")]
[Exclude(name="focusInEffect", kind="effect")]



July 24th, 2008 at 9:12 am
It is sort of true that “btn” won’t be accessible outside that component, but there are limits on this. Let’s say that your custom component is in the file MyComponent.mxml, and that we would therefore instantiate it within another file as follows:
<myNamespace:MyComponent id=”myComponent” />
If we try to use the btn attribute within that tag, it will not be available to us. However, we can still access the button subcomponent for things such as binding. Thus we can add another tag which would bind to the button subcomponent, like this:
<mx:Text text=”{myComponent.btn.label}” />
Not only would this not cause a compiler error, but it would work correctly. Further, we can access the subcomponent button using ActionScript, such as this:
this.myComponent.btn.label = “modified”;
And that will also work. Thus it turns out that the [Exclude] is limited to altering what attributes are available within the tag that declares a component.
July 24th, 2008 at 9:42 am
Quick follow-up. It turns out that the Exclude metadata tag does even less than I thought it does. All it does is make it so the excluded property will not show up in the code hinting list. You can still use the property, even within the tag declaring that component that it is a property of. So, continuing the example from my previous comment, it will work just fine to do the following:
<myNamespace:MyComponent id=”myComponent” btn.label=“modified” />