Mutually Exclusive Shared ComboBox – Flex 4

This custom component I developed extends ComboBox, and allows a number of ComboBox based components to be added to the stage (dynamically or statically), and they are all linked via a shared DataProvider.

In essence, the ComboBox components are shared, and selecting an item in one comboBox removes that item as a selectable option in any other ComboBox. Inversely, if a ComboBox is removed, its selected item becomes available to the others again.

Shared ComboBox demo (right click to view source)

  • IoC to inject a class with a static xmlList into the ComboBox components
  • getQualifiedClassName() and getDefinitionByName() to create Class references on the fly
  • Use of weak reference event listeners and custom events
  • Custom Spark Button class and button Skin
  • Forced garbage collection using the following:
* Forces a garbage collection to occur. More reliable
* than System.gc();
private function garbageCollectionHack():void{

   try {
       new LocalConnection().connect('foo');

       new LocalConnection().connect('foo');

     } catch (e:*) {}

In you add a change event handler, you can reference the sharedComboBox.ownedItem (this is handy if you passed in objects – in xml form – to your dataProvider)

Tags: , , , ,

Leave a Reply

You must be logged in to post a comment.