I have a small portion of code that crashes all the time.

Here's the code:
Application: "BindProblem.mxml"

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="vertical" creationComplete="begin()"
    xmlns:local="*">
    <mx:Script>
        <![CDATA[
            import Dummy;
           
            [Bindable] private var provider:Array;
             
            private function begin():void {
                var row1:Dummy = new Dummy();
                row1.field1 = "Field data 1 row 1";
                row1.field2 = "Field data 2 row 1";
                var row2:Dummy = new Dummy();
                row2.field1 = "Field data 1 row 2";
                row2.field2 = "Field data 2 row 2";
               
                provider = [ row1, row2 ];    
            }
        ]]>
    </mx:Script>
    <mx:Repeater id="rp" dataProvider="{provider}">
        <mx:VBox>
            <mx:HBox>
                <mx:Label text="Label1:"/>
                <local:BoxComp>
                    <mx:Text text="{rp.currentItem.field1}"/>
                </local:BoxComp>
            </mx:HBox>
            <mx:HBox>
                <mx:Label text="Label2:"/>
                <mx:Box>
                    <mx:Text text="{rp.currentItem.field2}"/>
                </mx:Box>
            </mx:HBox>
        </mx:VBox>
    </mx:Repeater>
</mx:Application>

Component: "BoxComp.mxml"
<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml";>
   
</mx:Box>
Class Dummy: "Dummy.as"
package {
   
    [Bindable]
    public class Dummy {
       
        public var field1:String;
        public var field2:String;
       
        public function Dummy() {
       
        }
    }
}

Just run it and it will crash with error:
TypeError: Error #1034: Type Coercion failed: cannot convert 
mx.controls::[EMAIL PROTECTED] to Array.

If you change:

<local:BoxComp>
    <mx:Text text="{rp.currentItem.field1}"/>
</local:BoxComp>

for:

<mx:Box>
    <mx:Text text="{rp.currentItem.field1}"/>
</mx:Box>

it works!!

Any idea what's going on?
Is this a bug? Any ideas to workaround?

Thanks,

-Paulo

Reply via email to