Hey everyone,
I am currently doing a project for someone who wants to be able to update it with their own pictures and menu items, so naturally, I opted to incorporate XML for pretty much everything. I’ve run into a problem though. When clicking on a menu item, I would like the pictures that are attributed with that button on load in a gallery like fashion. Right now, I’m trying to run a trace to get the right amount of nodes to appear with the right group. Below is my XML file and my AS.
<?xml version="1.0"?>
<menu>
<item titles="Bookshelf" gallery="bookshelf.swf">
<pic small="pics/bookshelf/photo1sm.jpg" big="pics/bookshelf/photo1big.jpg"></pic>
<pic small="pics/bookshelf/photo2sm.jpg" big="pics/bookshelf/photo2big.jpg"></pic>
<pic small="pics/bookshelf/photo3sm.jpg" big="pics/bookshelf/photo3big.jpg"></pic>
<pic small="pics/bookshelf/photo4sm.jpg" big="pics/bookshelf/photo4big.jpg"></pic>
</item>
<item titles="Boxes" gallery="boxes.swf">
<pic small="pics/boxes/photo1sm.jpg" big="pics/boxes/photo1big.jpg"></pic>
<pic small="pics/boxes/photo2sm.jpg" big="pics/boxes/photo2big.jpg"></pic>
<pic small="pics/boxes/photo3sm.jpg" big="pics/boxes/photo3big.jpg"></pic>
<pic small="pics/boxes/photo4sm.jpg" big="pics/boxes/photo4big.jpg"></pic>
<pic small="pics/boxes/photo5sm.jpg" big="pics/boxes/photo5big.jpg"></pic>
<pic small="pics/boxes/photo6sm.jpg" big="pics/boxes/photo6big.jpg"></pic>
<pic small="pics/boxes/photo7sm.jpg" big="pics/boxes/photo7big.jpg"></pic>
<pic small="pics/boxes/photo8sm.jpg" big="pics/boxes/photo8big.jpg"></pic>
<pic small="pics/boxes/photo9sm.jpg" big="pics/boxes/photo9big.jpg"></pic>
</item>
<item titles="Hope Chest" gallery="chest.swf">
<pic small="pics/chest/photo1sm.jpg" big="pics/chest/photo1big.jpg"></pic>
<pic small="pics/chest/photo2sm.jpg" big="pics/chest/photo2big.jpg"></pic>
<pic small="pics/chest/photo3sm.jpg" big="pics/chest/photo3big.jpg"></pic>
<pic small="pics/chest/photo4sm.jpg" big="pics/chest/photo4big.jpg"></pic>
<pic small="pics/chest/photo5sm.jpg" big="pics/chest/photo5big.jpg"></pic>
<pic small="pics/chest/photo6sm.jpg" big="pics/chest/photo6big.jpg"></pic>
</item>
<item titles="Desk" gallery="desk.swf">
<pic small="pics/desk/photo1sm.jpg" big="pics/desk/photo1big.jpg"></pic>
<pic small="pics/desk/photo2sm.jpg" big="pics/desk/photo2big.jpg"></pic>
<pic small="pics/desk/photo3sm.jpg" big="pics/desk/photo3big.jpg"></pic>
<pic small="pics/desk/photo4sm.jpg" big="pics/desk/photo4big.jpg"></pic>
<pic small="pics/desk/photo5sm.jpg" big="pics/desk/photo5big.jpg"></pic>
<pic small="pics/desk/photo6sm.jpg" big="pics/desk/photo6big.jpg"></pic>
<pic small="pics/desk/photo7sm.jpg" big="pics/desk/photo7big.jpg"></pic>
<pic small="pics/desk/photo8sm.jpg" big="pics/desk/photo8big.jpg"></pic>
<pic small="pics/desk/photo9sm.jpg" big="pics/desk/photo9big.jpg"></pic>
<pic small="pics/desk/photo10sm.jpg" big="pics/desk/photo10big.jpg"></pic>
<pic small="pics/desk/photo11sm.jpg" big="pics/desk/photo11big.jpg"></pic>
<pic small="pics/desk/photo12sm.jpg" big="pics/desk/photo12big.jpg"></pic>
<pic small="pics/desk/photo13sm.jpg" big="pics/desk/photo13big.jpg"></pic>
</item>
<item titles="Crown Moulding" gallery="moulding.swf">
<pic small="pics/moulding/photo1sm.jpg" big="pics/moulding/photo1big.jpg"></pic>
<pic small="pics/moulding/photo2sm.jpg" big="pics/moulding/photo2big.jpg"></pic>
</item>
<item titles="TV Stand" gallery="stand.swf">
<pic small="pics/stand/photo1sm.jpg" big="pics/stand/photo1big.jpg"></pic>
<pic small="pics/stand/photo2sm.jpg" big="pics/stand/photo2big.jpg"></pic>
<pic small="pics/stand/photo3sm.jpg" big="pics/stand/photo3big.jpg"></pic>
<pic small="pics/stand/photo4sm.jpg" big="pics/stand/photo4big.jpg"></pic>
<pic small="pics/stand/photo5sm.jpg" big="pics/stand/photo5big.jpg"></pic>
<pic small="pics/stand/photo6sm.jpg" big="pics/stand/photo6big.jpg"></pic>
<pic small="pics/stand/photo7sm.jpg" big="pics/stand/photo7big.jpg"></pic>
<pic small="pics/stand/photo8sm.jpg" big="pics/stand/photo8big.jpg"></pic>
<pic small="pics/stand/photo9sm.jpg" big="pics/stand/photo9big.jpg"></pic>
<pic small="pics/stand/photo10sm.jpg" big="pics/stand/photo10big.jpg"></pic>
<pic small="pics/stand/photo11sm.jpg" big="pics/stand/photo11big.jpg"></pic>
<pic small="pics/stand/photo12sm.jpg" big="pics/stand/photo12big.jpg"></pic>
</item>
<item titles="Tables" gallery="tables.swf">
<pic small="pics/tables/photo1sm.jpg" big="pics/tables/photo1big.jpg"></pic>
<pic small="pics/tables/photo2sm.jpg" big="pics/tables/photo2big.jpg"></pic>
<pic small="pics/tables/photo3sm.jpg" big="pics/tables/photo3big.jpg"></pic>
<pic small="pics/tables/photo4sm.jpg" big="pics/tables/photo4big.jpg"></pic>
<pic small="pics/tables/photo5sm.jpg" big="pics/tables/photo5big.jpg"></pic>
<pic small="pics/tables/photo6sm.jpg" big="pics/tables/photo6big.jpg"></pic>
<pic small="pics/tables/photo7sm.jpg" big="pics/tables/photo7big.jpg"></pic>
<pic small="pics/tables/photo8sm.jpg" big="pics/tables/photo8big.jpg"></pic>
<pic small="pics/tables/photo9sm.jpg" big="pics/tables/photo9big.jpg"></pic>
<pic small="pics/tables/photo10sm.jpg" big="pics/tables/photo10big.jpg"></pic>
<pic small="pics/tables/photo11sm.jpg" big="pics/tables/photo11big.jpg"></pic>
<pic small="pics/tables/photo12sm.jpg" big="pics/tables/photo12big.jpg"></pic>
<pic small="pics/tables/photo13sm.jpg" big="pics/tables/photo13big.jpg"></pic>
</item>
</menu>
import mx.transitions.Tween;
import mx.transitions.easing.*;
var i:Number;
function loadXML(loaded) {
if (loaded) {
var xmlNode = this.firstChild;
var menuItems = xmlNode.childNodes;
var smallPics:Array = new Array();
for (i=0; i<=menuItems.length-1; i++) {
var menuTitles = xmlNode.childNodes*.attributes.titles;
smallPics.push(xmlNode.childNodes*.childNodes*.attributes.small);
var singleNodes = xmlNode.childNodes*;//Which Node Is Tracked
attachButtons();
_root["button"+i].name_txt.text = menuTitles;
_root["button"+i].onRollOver = onButtonRollOver;
_root["button"+i].onRollOut = onButtonRollOut;
_root["button"+i].onRelease = function() {
for (j=0; j<=xmlNode.firstChild.childNodes.length-1; j++) {//Amount Of Nodes
trace(singleNodes.childNodes[j].attributes.small);
}
};
}
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("menu.xml");
function attachButtons() {
attachMovie("button","button"+i,i,{_x:0, _y:(i*20)+50});
}
function onButtonRollOver() {
var tw:Tween = new Tween(this.name_txt, "_x", Strong.easeOut, this.name_txt._x, 20, 0.5, true);
var tw2:Tween = new Tween(this.button_bg, "_alpha", Strong.easeOut, this.button_bg._alpha, 100, 0.5, true);
}
function onButtonRollOut() {
var tw:Tween = new Tween(this.name_txt, "_x", Strong.easeOut, this.name_txt._x, 9, 0.5, true);
var tw2:Tween = new Tween(this.button_bg, "_alpha", Strong.easeOut, this.button_bg._alpha, 60, 0.5, true);
}
Right now, when you press a button, it traces out the first group of nodes. What I want to happen is to trace out the group of nodes that correspond with that menu item. If anyone has any insight as to what I’m doing wrong, any help is much appreciated. Thanks everyone!