explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

Private functions in Flex Source and what you can do about it


If you have ever tried to do component development, you know it can sometimes be a pain because certain methods in the parent class are marked private and are inaccessible to your class. Take for instance the comboBox. When making my custom component (which subclasses comboBox), I wanted to customize some event handling for the listBase. The getDropdown function is where you would (if you could), override the native event handling and plug in your own functionality. But I can’t. Why? Its marked private. “Couldn’t you override the assigned event handlers for the listBase?” Hmmm. Sounds like a plan. Nope. Let’s take a look to see why.

  • dropdown_changeHandler
  • dropdown_scrollHandler
  • dropdown_itemRollOverHandler
  • dropdown_itemRollOutHandler
  • dropdown_mouseDownOutsideHandler
  • dropdown_mouseWheelOutsideHandler
  • dropdown_itemClickHandler

All these guys are marked private instead of protected. Certainly alot of the ‘heavy lifting’ has been for most developers in that they will probably never need to modify these methods. But for a component developer this can pose major problems. In my particular case I wanted to override the dropdown_itemClickHandler in order to intercept and do something to the event getting dispatched. “Couldn’t you just add an eventListener in your subclass and tie in your functionality there?“. Yes, I could but then I would still have the super’s event handler logic taking place, which I don’t want.

So what are the solutions here? Well you have two options at the moment.

  1. live with it and find another solution.
  2. copy the super code to a project directory and change the needed code to protected.

I did the latter. It doesn’t sit well with me but I will live. But there is one more thing I did. I suggest if you ever are in the same situation that you save this link. Let Adobe know about it and gripe about it until it gets changed in the next update.


I can understand in the rush to get something out the door that old AS2 programming habits creeped in. But this should be remedied on the next update.


4 thoughts on “Private functions in Flex Source and what you can do about it

  1. Came across your blog while I was having to do somethings similar with ComboBox. I just wanted to mention that in some cases if its a private handler function that you want to override, then you can remove the listener from the derived instance member and then add something else back.

  2. found your blog by googling for dropdown_mouseDownOutsideHandler …

    thanks for the tip… I’ll also try Ian’s suggestion.


  3. I came across, having the exact issue but with VideoDisplay object. pain really. I can’t live with the pain so I had to copy the classes and start modification…so much complicated…hehe..I think we will have similar wish in future.

  4. I don’t understand Ian’s tip, how do you remove the listener if the listener is Private? Isn’t that the same problem?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s