1 Reply Latest reply on Feb 12, 2010 2:00 PM by msakrejda

    TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@2dcb5041 to mx.collections.Arra

    JohnMerlino Level 1

      Hey all,

       

      I get this error no matter what changes I make:

       

      TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@2dcb5041 to mx.collections.ArrayCollection.

       

      This is what I have:

       

          <fx:Script>
              <![CDATA[
                  import mx.events.FlexEvent;
                  import mx.controls.Alert;
                  import mx.rpc.events.FaultEvent;
                  import mx.rpc.events.ResultEvent;
                  import mx.collections.ArrayCollection;
                 
                  [Bindable]
                  private var requestsFeed:ArrayCollection;
                 
                  private function requestsResultHandler(event:ResultEvent):void
                  {
                       requestsFeed = event.result.confirm_request
                  }
                 
                  private function dataFaultHandler(event:FaultEvent):void
                  {
                      Alert.show(event.fault.message, "Could not load data");
                  }   
              ]]>

       

          <s:DropDownList x="217" y="51" id="confirm_requestList" prompt="Select a request number" dataProvider="{requestsFeed}" labelField="request_num" />

       

      Any ideas of how to fix this? Thanks.

        • 1. Re: TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@2dcb5041 to mx.collections.Arra
          msakrejda Level 4

          Flash Player actually is telling you what the problem is. Your requestsFeed variable is declared as an ArrayCollection, but in the result handler, you're assigning an XMLList to it. You need compatible types, or to properly adapt the types. E.g., this should work:

           

           

           

           

              <fx:Script>
                  <![CDATA[
                      import mx.events.FlexEvent;
                      import mx.controls.Alert;
                      import mx.rpc.events.FaultEvent;
                      import mx.rpc.events.ResultEvent;
                      import mx.collections.ArrayCollection;
                     
                      [Bindable]
                      private var requestsFeed:ArrayCollection = new ArrayCollection();
                     
                      private function requestsResultHandler(event:ResultEvent):void
                      {
                           requestsFeed.list = event.result.confirm_request
                      }
                     
                      private function dataFaultHandler(event:FaultEvent):void
                      {
                          Alert.show(event.fault.message, "Could not load data");
                      }   
                  ]]>