Adobe Flex: Cannot Convert XMLList to mx.collections.IList

前端 未结 2 702
独厮守ぢ
独厮守ぢ 2021-01-24 19:42

My Flex app runs a service to a php page that pulls data from my database, then structures the result in an XML format. I created a new XMLList called testList outs

相关标签:
2条回答
  • 2021-01-24 20:11

    E4X expressions return lists of matching XML. xml.user gives you an XMLList of all user elements. You can use XMLListCollection, which implements IList, to wrap the result so you can use it as a dataprovider.

    var xml:XML = new XML(event.result as String);
    var list:IList = new XMLListCollection(xml.user);
    

    The other option is to loop though the XMLList and add it to an array or whatever collection you need. If you know for sure that there is only one user, you can do this instead:

    var user:XML = xml.user[0];
    
    0 讨论(0)
  • 2021-01-24 20:14

    You probably are using this inside a module or a swf that you've loaded, and the loader has a different applicationDomain than the parent, and some other loaded module or swf is also using XMLList or XMLListCollection. Without more details on your architecture, I can only tell you to make sure the parent applicationDomain loads in XMLList and/or XMLListCollection before either child, or make sure they both share the parent's applicationDomain.

    0 讨论(0)
提交回复
热议问题