Simple question.  

Why does example 1 below work as expected, but example 2 does not 
(the "Pear" checkbox is not added)?  I thought repeaters, like other 
components, responded to changes in the dataprovider through 
databinding.

------------------
EXAMPLE 1

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
applicationComplete="init()">
        
        <mx:Script>
                <![CDATA[
                        
                [Bindable]
                private var myData:Array = [{ label:"Banana" }, { 
label:"Pear" }, { label:"Orange" } ];
                
                ]]>
        </mx:Script>
        
        <mx:Repeater id="myRepeater" dataProvider="{myData}">
                <mx:CheckBox id="checkBox" 
label="{myRepeater.currentItem.label}" />
        </mx:Repeater>
        
</mx:Application>
------------------

EXAMPLE 2

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
applicationComplete="init()">
        
        <mx:Script>
                <![CDATA[
                        
                [Bindable]
                private var myData:Array = [ { label:"Banana" } ];
                
                [Bindable]
                private var fruit1:Object = new Object();
                
                private function init():void
                {
                        fruit1.label = "Pear";
                        myData.push(fruit1);
                }
                
                ]]>
        </mx:Script>
        
        <mx:Repeater id="myRepeater" dataProvider="{myData}">
                <mx:CheckBox id="checkBox" 
label="{myRepeater.currentItem.label}" />
        </mx:Repeater>
        
</mx:Application>

------------------

How would you handle a situation like in Example 2, where the 
dataprovider changes after the repeater initally runs (in this case, 
after the applicationComplete event)?

Thanks.

Jason Merrill

Reply via email to