views:

61

answers:

1

I'm trying to set up a form that presents a combobox when an ArrayCollection it's bound to has several items, and doesn't present one when it's empty or only has one item. I've tried doing this by creating this class, but unfortunately, the data provider I've bound to is never not empty at the time the setter executes. Is there a different way I should approach this?

public class ComboboxOrFail extends ComboBox
{
 public function ComboboxOrFail()
 {
  super();
 }

 public override function get dataProvider():Object
 {
  return super.dataProvider;
 }

 public override function set dataProvider(value:Object):void
 {
  this.visible = (value && value.length && value.length > 1);
  super.dataProvider = value;
 }
}
+1  A: 

I've done this in a different way:

<mx:ComboBox dataProvider="{myData}" visible="{myData != null &amp;&amp; myData.length > 1}"/>

Assuming that myData is bindable, this should do the trick!

Doug Hays