Hi,

I have a custom object (defined in .as) with this property:

[Bindable]
        public class ExperimentModel implements IXmlSerializable
        {
...

//element type is subclass of Therapy
                public var therapies:ArrayCollection = new ArrayCollection();
                public function addTherapy(element:Therapy):void {
                        
                        therapies.addItem(element);
                        therapies.dispatchEvent(new CollectionEvent(
CollectionEvent.COLLECTION_CHANGE ) );  
                }

I then have another class which sometimes works with databinding,
sometimes not.  


<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"; 
              xmlns:com="therapyComponents.*"
              layout="vertical" width="400" height="300">
        <mx:Script>
                <![CDATA[
                        import mx.events.CollectionEvent;
                        import com.entelos.realab.model.Therapy;
                        import com.entelos.realab.vo.PatientVO;
                        import mx.collections.ArrayCollection;
                        import com.entelos.realab.model.ExperimentModel;
                        [Bindable]
                        public var model:ExperimentModel;
                        
                        private function getlen(a:ArrayCollection):Number {
                                return a.length;
                        }
                        
                        private function negate( value:Number ):Number
                        {
                                return -value;
                        }
                ]]>
        </mx:Script>

        <mx:Text width="100%" id="t1"  text="{model.therapies.length}"/> <!--
this works -->
        <mx:Text width="100%" id="t2"  text="{getlen(model.therapies)}"/>
<!-- this does not -->
        <mx:Text width="100%" id="t3" 
text="{negate(model.therapies.length)}"/> <!-- this works -->
        <com:boundText val="{model.therapies}"/> <!-- this does not -->
        <mx:DataGrid  dataProvider="{model.therapies}"/> <!-- this works -->
        
</mx:Panel>

Obviously I can use the .length property for my bound therapies
ArrayCollection but not my therapies as-is.  Why is this?

Thanks


Reply via email to