Array from XML Attributes…and more

Hello all
As it’s my first post on these forums : first of all, I’ll have to say many thanks to Kirupa & Contributors here for the useful resources and tutorials.

That said, I’m actually having a problem :sure:

hoping it won’t be a too long post :

  • I’m working on my small portflio website with the following principle : I have some .php that gathers stuff from my DB and outputs the found datas as an XML file.

  • I load this dynamically created XML with some simple functions based on tutorials found here (thank yous again)

  • For the infos diplayed on my Stage, the following happens: an “Create empty movie clip” action, then an “attachMovie” from my Library of a MC which will contains all the gathered datas (a thumbnail and its name).

  • While the datas from the XML being read and the MC’s loaded on the Stage with a SetInterval function , i want to retrieve the main information that will allow me to “filter” the display of all the MC’s loaded on the stage (these info. are the thumbnail’s current name once loaded and its category found on the corresponding XML attributes ) knowing that these main 2 infos are gathered within 2 dynamic text boxes within each MC.

  • So now I’m trying to store all the desired values within 2 arrays : 1 for the MC’s current name (as it appears on the stage) and 1 for its associated category (does this thumbnail belongs to paintings, drawings, webdesign, … and so on)

As the Datas are being displayed and the Mc’s are loading , I have a simple Trace (Thumbs* +" = " +Categories*); that works well… but the hell begins here :slight_smile:

Basically, what I’d like to achieve is doing a filter that “broadcasts” some property to a given set of loaded MC’s, knowing they eventually belong to this “x” category.

But all my trials to store and retrieve arrays once all my XML is loaded don’t work. And obviously I cannot even access my arrays once the XML has loaded and all the MC’s are displayed on stage…

Now for the lightened code ( I deleted the unnecessary stuff —and yes it’s mostly based on the ‘create a dynamic XML menus with submenus’ tutorial found here :wink:

on Frame 2 :


GenerateMenu = function (container, name, x, y, depth, node_xml) {
	var colonne = 0;
	var ligne = 0;
	var sw = node_xml.childNodes.length;
	var i = 0;
	var myInt;
	var filetype;
	var curr_node;
	var curr_item;
	
	var curr_menu:MovieClip = imgd.placeholder.createEmptyMovieClip(name, depth);
	
	//trace(sw);
	
	setImg = function () {
		
		var Thumbs = new Array();
		var curr_item:MovieClip = curr_menu.attachMovie("menuitem", "mmc_"+i, i);
		Thumbs* = curr_item;  
		trace (Thumbs*); // ok items are displays
		
		curr_node = node_xml.childNodes*;
		curr_item.itemin.thumbnail.createEmptyMovieClip("thumb", i);
		
		i++;
		if (i == sw) {
			clearInterval(myInt);
			}
		if (colonne == 6) {
			colonne = 0;
			ligne++;
			}
		curr_item._x = colonne*100+6;
		curr_item._y = ligne*80+5;
		colonne++;

		curr_item.action = curr_node.attributes.action;
		curr_item.variables = curr_node.attributes.variables;
		curr_item.type.text = curr_node.attributes.type;
		curr_item.name.text = curr_node.attributes.name;
		curr_item.desc = curr_node.attributes.desc;
		filetype = curr_item.type.text;
		
		var Categories = new Array();
		var cats:String = curr_item.type.text; 
		Categories* = cats; 
		trace (Thumbs*+" = "+Categories*); // ok categories displayed
		
		curr_item.onRelease = function() {
			Actions[this.action](this.variables);
		};
		

	};
	myInt = setInterval(setImg, 200);
};

Createmainmenu = function (x, y, depth, menu_xml) {
	GenerateMenu(this.imgd.placeholder, "mainmenu_mc", x, y, depth, menu_xml.firstChild);
	// in case the filter button works it may set here
	_root.bt_filter.onRelease = function() {
		trace("clip = "+ Thumbs[2] +", categorie ="+Categories[2]);//why undefined ???
	};
};

…And for Frame 3 :



menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok) {
	if (ok) {
		Createmainmenu(0, 0, 0, this);
		trace("XML loaded");
	} else {
		trace("Server not running");
		stop();
	}
};
menu_xml.load("portfolio.php");
stop();


//additionally , any MC (not from the loaded list) placed on the main timeline should acts as a button and be able to "filter" the MC's from the list that belongs to "x" category

_root.bt_filter.onRelease = function() {
	trace("clip = "+ Thumbs* +", categorie ="+Categories*); //...
};


K.

ps : I know, I know I’m still using the good old “_root” instead of “this” :pleased: