If you have ever peered into one of the mx classes, you will probably have noticed the ubiquitous
mx_internal namespace being used. For those of you not familiar with the usage of namespace, it is basically a system of allowing classes to peer into other classes for needed code. The most common namespaces are:
mx_internal namespace is a kind of extension of the
internal namespace, but rather than being limited to seeing other internal properties and methods of just a particular package, it is able to see code through out the entire mx framework. For example, the Panel, which resides at
mx_internal function getTitleBar(), which makes the
protected var titleBar visible to any other component within the mx framework.
So what can this do for you as a component developer. Well, you can easily tap into these methods and properties yourself. All you need to do is add two lines of code to your class.
use namespace mx_internal;
Now any property or method with the namespace
mx_internal is accessible to your class. But be forewarned, there are two issues with doing this.
- Adobe has written in their code the following caution:
This namespace is used for undocumented APIs — usually implementation details — which can’t be private because they need to visible to other classes. APIs in this namespace are completely unsupported and are likely to change in future versions of Flex.
This means you might be in for a surprise the next Flex SDK update you do.
- You don’t get code hinting in your IDE since technically speaking you are not even supposed to be implementing these APIs.
Anyway…hope this might provide some solutions to any component developers out there that are stuck with a particular extension problem.
[EDIT 2007.05.14] – A buddy of mine found a cool but not-so-OOP way of accessing a component instance’s mx_internal properties. I would be very careful with getting into the habit of this. Check it out.