AS 3.0 - find the nr of items in an xml that have a specific name before looping thro
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 moviefor each (var row:XML in xml..rss::row)
{
if (row.@ows_Sub_x002d_Site == filterBy){
// here i put the code to build the menu }
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.
精彩评论