I had a similar problem and while somewhat unrelated this may help. I wanted
to set an image inside an itemRenderer (for a Listbox) depending on the data
for the current row. I came up with this, thanks to Tink for the idea:
 
 
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"; height="22"
horizontalAlign="left" 
 verticalAlign="middle" horizontalScrollPolicy="off"
verticalScrollPolicy="off">
 
 <mx:Script>
  <![CDATA[
  
   [Bindable]
   private var _data:Object;
   [Bindable]
   private var _imgIcon:String;
   
   [Bindable]
   override public function get data():Object
   {
    return _data;
   }
   
   override public function set data( value:Object ):void
   {
    if (value)
     _data = value;
     if (_data.gender == "male")     
     {
       _imgIcon = "assets/male.png";  
     }
     else
     {
       _imgIcon = "assets/female.png"; 
     }    
   }
   
  ]]>
 </mx:Script> 
 <mx:Image source="{_imgIcon}" />
 <mx:Text text="{_data.username}" selectable="false" fontSize="13"
fontWeight="bold"/>
 <mx:Spacer width="100%" height="100%"/>
</mx:HBox>
 
 
Basically I overwrote the setter and getter for data (the data object is
what the itemRenderer feeds off).
 
Combobox is list based so this approach should work for you.
 
Stefan
 
 
 
 


  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of ben.clinkinbeard
Sent: 28 November 2006 20:30
To: [email protected]
Subject: [flexcoders] Re: Binding to a custom method: possible?



Anyone? 

--- In [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com> ups.com,
"ben.clinkinbeard"
<[EMAIL PROTECTED]> wrote:
>
> There was a similar question asked here recently but my needs are
> different so I am starting a new thread. My needs are as follows: I
> have a ComboBox whose enabled state needs to be determined by several
> factors, thus the need for a custom method. The problem is that this
> doesn't seem to work, no matter how I try it. Am I missing something
> or is this just not possible (meaning I have to set a property and
> bind to that)? Fake sample code below:
> 
> [Bindable]
> private function isEnabled():Boolean
> {
> if(conditionA)
> {
> if(conditionB)
> {
> return true;
> }
> else
> {
> return false;
> }
> }
> }
> 
> <mx:ComboBox id="cb" enabled="{isEnabled()}"/>
> 
> 
> Thanks,
> Ben
>



 

Reply via email to