mx_internal
Sometimes you want to change the behavior of a Flex component but its hidden behind a private method or variable so you can't subclass it. Thankfully they provide the source so you can just create your own version. This is heavy handed and in some cases you just need to tweak things a little. Many components within the Flex framework have methods and properties flagged as mx_internal. These you can access without having to do anything too funky.
As an example lets change the restrict set on the input field of a NumericStepper.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:Script> <![CDATA[ import mx.core.mx_internal; use namespace mx_internal; private function setupStepper():void { stepper.mx_internal::inputField.restrict = "0-9"; } ]]> </mx:Script> <mx:NumericStepper id="stepper" creationComplete="setupStepper();"/> </mx:Application>
The key things to note are:
- import mx.core.mx_internal;
Import the namespace that is going to be used - use namespace mx_internal;
Tell Actionscript that is a namespace - mx_internal::inputField
Prefix the property name with its namespace
That's all there is to it. Happy hacking.