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.
Comments
Posted by: Kyle | May 14, 2007 12:22 PM
Posted by: Carlos Alexandre de Assis | April 29, 2008 2:05 PM
Posted by: Justin | July 15, 2008 11:04 AM
Posted by: sanjeev rajput | September 23, 2008 2:29 AM
Posted by: Koojav | April 20, 2011 4:02 AM
Posted by: Sachin | July 19, 2011 3:34 AM