tags:

views:

9

answers:

1

I'm trying to resolve the following:

I'v got a long xml file with a node called 'ows_Sub_x002d_Site' - this has several different values (e.g Home, about us e.t.c) which i then filter to make sure only items with that specific value are then looped thro to build a menu. That part i got sorted (see below). The problem i have is that i need to know how many items there are in the xml file with that value before i loop thro the xml and build the menu (so i can determine the overall width of the menu e.t.c).

any clues?

...

function buildTheMenu():void {

var filterBy:String = "Home"; var rss:Namespace = new Namespace("#RowsetSchema"); var nrOfItems:Number = xml..rss::row.length();
var iconWidth:Number = 60; // set the size of the icons movie

for each (var row:XML in xml..rss::row)

{

if (row.@ows_Sub_x002d_Site == filterBy){

// here i put the code to build the menu }

A: 

Instead of setting your menu directly from the XML, you could parse your xml and create an Object or a class to hold the xml data with any properties you may need. Then create your menu using the object properties.

PatrickS
figured it out. loop thro the xml to create arrays that hold the filtered data. then run a for loop (set to run once the initial filtering loop is completed) to build the menu.
Mark
yep that works! depending on the xml complexity, i like to use custom classes as it allows me to perform operations and generally deal with all the logic issues before handling the view ( in your case a menu ). handy if later on you change your mind on the design!
PatrickS