Ah, got it.

The <mx:Model> tag converts everything to a flat object.  So the minute you
use it, you no longer have xml.

It's still easy enough to loop through though.

var result:Object = myData.getItemAt(0);
for (var name:String in result)
{
trace(name + " :: " + result[name]);
}

should output
apple :: 81768
orange :: 60310
banana :: 43357


On Wed, Jul 2, 2008 at 1:46 PM, Stephen More <[EMAIL PROTECTED]> wrote:

>   Here is my output:
>
> DEBUG: 2 null
> [object Object]
> CHECK : false
> CHECK : false
>
> Here is all the code:
> <?xml version="1.0"?>
> <!-- charts/XMLFileToArrayCollectionDataProvider.mxml -->
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> width="100%" height="100%">
> <mx:Script>
> import mx.utils.ArrayUtil;
> </mx:Script>
>
> <mx:Model id="results" source="../assets/data.xml"/>
> <mx:ArrayCollection id="myData"
> source="{ArrayUtil.toArray(results.result)}"
> />
>
> <mx:Panel title="Line Chart">
> <mx:LineChart id="chart" dataProvider="{myData}" showDataTips="true">
> <mx:horizontalAxis>
> <mx:CategoryAxis categoryField="month"/>
> </mx:horizontalAxis>
> <mx:series>
> <mx:LineSeries yField="banana" displayName="Banana"/>
> <mx:LineSeries yField="apple" displayName="Apple"/>
> <mx:LineSeries yField="orange" displayName="Orange"/>
> </mx:series>
> </mx:LineChart>
>
> <mx:Button id="iconButton" label="Button with Icon"
> labelPlacement="right" color="#993300"
> click="printMessage(event);"/>
>
> <mx:Script>
> <![CDATA[
>
> import flash.events.Event;
>
> // Event handler function to print a message
> // describing the selected Button control.
> private function printMessage(event:Event):void {
> //message.text += event.target.label + " pressed" + "\n";
>
>
> var myXML:XML;
> myXML = myData.getItemAt(0) as XML;
> trace( "DEBUG: " + myData.length + " " + myXML );
> trace( myData.getItemAt(0) );
> trace("CHECK : " + (myData.getItemAt(0) is XML));
> trace("CHECK : " + (myData.getItemAt(0) is XMLList));
> }
>
> ]]>
> </mx:Script>
>
> </mx:Panel>
> </mx:Application>
>
>
> On Wed, Jul 2, 2008 at 3:34 PM, Sean Clark Hess <[EMAIL 
> PROTECTED]<seanhess%40gmail.com>>
> wrote:
> > What do you get when you trace myData.getItemAt(0)? That will return null
> > if it isn't an XML. You can do this too:
> >
> > trace("CHECK : " + (myData.getItemAt(0) is XML));
> >
> > You can check to see if it is an XMLList too, but I thought looking at
> it,
> > it seemed like a flat xml.
> >
> > On Wed, Jul 2, 2008 at 1:32 PM, Stephen More <[EMAIL 
> > PROTECTED]<stephen.more%40gmail.com>>
> wrote:
> >>
> >> Thats what I was thinking but when I try:
> >>
> >> var myXML:XML;
> >> myXML = myData.getItemAt(0) as XML;
> >> trace( "DEBUG: " + myXML );
> >>
> >> I get
> >> DEBUG: null
> >>
> >> On Wed, Jul 2, 2008 at 2:30 PM, Sean Clark Hess <[EMAIL 
> >> PROTECTED]<seanhess%40gmail.com>
> >
> >> wrote:
> >> > Each row is an xml object...
> >> >
> >> > So, (myData.getItemAt(i) as XML).children()
> >> >
> >> > Then you could loop through the children and ask them for their name.
> >> > After
> >> > the as XML step you can do anything you can normally do with the XML
> >> > object
> >> >
> >> > On Wed, Jul 2, 2008 at 12:11 PM, Stephen More <[EMAIL 
> >> > PROTECTED]<stephen.more%40gmail.com>
> >
> >> > wrote:
> >> >>
> >> >> ( Example code taken from:
> >> >> http://livedocs.adobe.com/flex/201/html/charts_intro_108_12.html )
> >> >> Here is the dataset I am trying to work with:
> >> >>
> >> >> <data>
> >> >> <result month="Jan-04">
> >> >> <apple>81768</apple>
> >> >> <orange>60310</orange>
> >> >> <banana>43357</banana>
> >> >> </result>
> >> >> <result month="Feb-04">
> >> >> <apple>81156</apple>
> >> >> <orange>58883</orange>
> >> >> <banana>49280</banana>
> >> >> </result>
> >> >> </data>
> >> >>
> >> >> The flex code will look like this:
> >> >> <mx:HTTPService
> >> >> id="srv"
> >> >> url="../assets/data.xml"
> >> >> useProxy="false"
> >> >> result="myData=ArrayCollection(srv.lastResult.data.result)"
> >> >> />
> >> >>
> >> >> How can I interrogate the ArrayCollection named myData so that it
> will
> >> >> return apple, orange, and banana ?
> >> >> I am not looking to get the numerical values, I want to get the xml
> >> >> name.
> >> >>
> >> >> -Thanks
> >> >> Steve More
> >> >
> >> >
> >
> >
>
>  
>

Reply via email to