I've got it almost working now. However, I'm trying to write a Filter function. 
This function will compare an ID and return a subset of IDs.

For example, an ID of 1 will return IDs with 11, 12, 13; an ID of 2 will return 
 IDs with 21, 22, 23, etc...

How do I compare IDs as strings to return what I want? Any tip in the right 
direction is greatly appreciated. 


--- In [email protected], "fumeng5" <fume...@...> wrote:
>
> Hmmm...I didn't know about the Repeater component, that's quite useful. 
> However, I should have explained that I'm not working with all the same 
> components. The XML is more complex than I posted. 
> 
> Here's what it really looks like:
> 
> <Class> 
> <Class_ID>1</Class_ID>
> <Class_Name>First Class</Class_Name>
> <Class_Amount></Class_Amount>
> </Class>
>  
> <Class> 
> <Class_ID>2</Class_ID>
> <Class_Name>Second Class</Class_Name>
> <Class_Amount>1.31</Class_Amount>
> </Class>
> 
> <Class> 
> <Class_ID>11</Class_ID>
> <Class_Name>Subclass of first class</Class_Name>
> </Class>
> 
> So my conditional for building the UI goes like this; if Class_Amount is 
> empty, this element has a subclass, i.e. 
> 
> for (var i:int=0; i<classData.length; i++){
> 
> if(classDataNode.Class_Amount == ''){
> var myButton:Button = new Button();
> myButton.label = classData[i].Class_Name;
> addChild( myButton );
> }else{
> var myRadioButton:RadioButton = new RadioButton();
> myRadioButton.label = classData[i].Class_Name;
> addChild( myRadioButton );
> }
>  }
> 
> I guess that with this scenario I'm not able to use the Repeater compnent and 
> will be forced to create a custom sorting of VBox child elements. 
> 
> Is that right? 
> 
> --- In [email protected], "Tracy Spratt" <tracy@> wrote:
> >
> > Use Repeater, and then just sort the dataProvider.
> > 
> >  
> > 
> > Tracy Spratt,
> > 
> > Lariat Services, development services available
> > 
> >   _____  
> > 
> > From: [email protected] [mailto:[email protected]] On
> > Behalf Of fumeng5
> > Sent: Friday, May 01, 2009 3:15 PM
> > To: [email protected]
> > Subject: [flexcoders] Sorting VBox elements based on an XML ID
> > 
> >  
> > 
> > 
> > 
> > 
> > 
> > 
> > Hi,
> > 
> > I've got something that I'm trying to troubleshoot and I can't figure it
> > out. I have an XML file full of elements, i.e.
> > 
> > <Class> 
> > <Class_ID>1</Class_ID>
> > <Class_Name>First Class</Class_Name>
> > </Class>
> > 
> > <Class> 
> > <Class_ID>2</Class_ID>
> > <Class_Name>Second Class</Class_Name>
> > </Class>
> > 
> > <Class> 
> > <Class_ID>11</Class_ID>
> > <Class_Name>Subclass of first class</Class_Name>
> > </Class>
> > 
> > <Class> 
> > <Class_ID>21</Class_ID>
> > <Class_Name>Subclass of second class</Class_Name>
> > </Class>
> > 
> > ...
> > 
> > Some classes have subclasses, i.e. Class ID 1 has a subclass of Class ID 11.
> > And Class ID 2 has a subclass of Class ID 21. 
> > 
> > My XML parsing class creates UI elements based on the XML and adds them to a
> > VBox, i.e. 
> > 
> > private var classXML:XML;
> > private var classData:XMLList;
> > 
> > for (var i:int=0; i<classData.length; i++){
> > 
> > var myButton:Button = new Button();
> > myButton.label = classData[i].Class_Name;
> > 
> > addChild( myButton );
> > }
> > 
> > When the XML first loads, the elements will be added to the VBox in the way
> > they're defined in the XML. 
> > 
> > However, I have to add the functionality that if a class is clicked it goes
> > to the top of the VBox and all its subclasses are listed right under it i.e.
> > Class ID 1 is clicked, it goes to the top with Class ID 11 right under it. 
> > 
> > This is what I don't know how to do. What is the best way to resort children
> > in a VBox based on ID? 
> > 
> > Any tips are very much appreciated. 
> > 
> > Thank you.
> >
>


Reply via email to