That issue is because pets.xml is generating an Object when there is a single item, instead of an Array (which it will do when there ai more than one pet defined). Take a look at mx.utils.ArrayUtil.toArray() is the docs for some code that will ensure you are always dealing with an Array.
- Doug --- In flexcoders@yahoogroups.com, "Christina Burnham" <[EMAIL PROTECTED]> wrote: > > --- In flexcoders@yahoogroups.com, "Doug Lowder" <douglowder@> > wrote: > > > > I missed the syntax problem but, interestingly enough, the app > works > > without the <mx:Array> tag - although I'm not sure why. Tracy is > > correct, the columns property is an Array so it should contain an > > <mx:Array> tag when declared in mxml. > > > > I added the mx:array even though it works (with more than pet in the > file) without it, and it still worked, but I was hoping it would > solve solve the problem I get when there is only one pet in the file. > Before it was just nothing, but since I added Tracy's mx:array it > pops up an error window in the browser that says this.. > TypeError: Error #1034: Type Coercion failed: cannot convert > mx.utils::[EMAIL PROTECTED] to Array. > at MethodInfo-505() > at Function/http://adobe.com/AS3/2006/builtin::apply() > at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall() > at mx.binding::Binding/::innerExecute() > at Function/http://adobe.com/AS3/2006/builtin::apply() > at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall() > at mx.binding::Binding/execute() > at _popFromXmlFileWatcherSetupUtil/setup() > at popFromXmlFile/initialize() > at > mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal : > :childAdded() > at mx.managers::SystemManager/::initializeTopLevelWindow() > at mx.managers::SystemManager/::frameEndHandler() > > > (This the the source) > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute"> > > <!-- populate datagrid from xml file --> > <mx:Model id="animalList" source="pets.xml"/> > > <mx:ArrayCollection id="anListAC" source="{animalList.pet}"/> > > <mx:DataGrid x="75" y="98" dataProvider = "{anListAC}"> > <mx:columns> > <mx:Array> > <mx:DataGridColumn headerText="Type" > dataField="anType"/> > <mx:DataGridColumn headerText="Name" > dataField="anName"/> > <mx:DataGridColumn > headerText="Living" dataField="anLiving"/> > </mx:Array> > </mx:columns> > </mx:DataGrid> > </mx:Application> >