Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-21612

If loaded xml contains only one node it isn't converted to arraycollection

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • Adobe Flex SDK Previous
    • None
    • RPC: HTTPService
    • None
    • Affected OS(s): All OS Platforms
      Affected OS(s): All OS Platforms
      Language Found: English

    Description

      Steps to reproduce:

      From http://forums.adobe.com/thread/511477?tstart=0

      The following mxml code imports an xml file and reports the length of the ArrayCollection into which the xml is loaded. If the xml file contains only a single <distractor> element I get this error message:

      TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::ObjectProxy@1d865821 to mx.collections.ArrayCollection.

      If the main xml node contains more than one <distractor> element, it works. Is there a problem with the way the xml is written or is there something else I'm doing wrong?

      Here's the xml. The file name is temp.xml:

      <?xml version="1.0" encoding="utf-8" standalone="no" ?>
      <distractorsList>
      <distractor>
      <testData>AAA</testData>
      </distractor>
      <distractor>
      <testData>BBB</testData>
      </distractor>
      </distractorsList>

      Here's the mxml code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.http.HTTPService;
      private function init():void{
      var service:HTTPService = new HTTPService();
      service.url = "temp.xml"
      service.method = "GET";
      service.addEventListener("result", recordsReturned);
      service.send()
      }
      private function recordsReturned(event:ResultEvent):void{
      var arrayCollection:ArrayCollection=event.result.distractorsList.distractor
      trace("xx="+arrayCollection.length)
      }
      ]]
      >
      </mx:Script>
      </mx:Application>
      Actual Results:

      Expected Results:

      Workaround (if any):

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            adobejira Adobe JIRA
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment