I’m trying to get my script to first attach the number of movieClips (buttons) as there are “mainButton” nodes in the XML. That part works. Then once the button is clicked it should display a second set of buttons depending on the number of “website” nodes. Attached is the Fla and XML i’ve been trying to work with, with some success. It creates the first set of buttons (displays 2). But if any one of the two buttons is pressed it only displays the second set of website nodes (the one with 9). Can anyone tell me what I’m doing wrong? I’ve been looking at this for too long now and I just can’t figure it out.
Hi markP, I have download the file. I can see what you are trying to do through the swf file, but everytime I open the fla file, my computer crash again and again. Sorry I can’t help you but as I said above read the tutorial from the link I gave you above.
Sorry about that Beebs, didn’t mean for that to happen. I read over the tutorial and my feeble mind couldn’t make it work for what I’m doing (although it’s really close to what I needed). So here’s what I have to end up with in case anyone is interested. It works just fine but it’s not very robust to let the use keep adding new “main” buttons from expanding the xml. I also had to add a new attribute to the first level node called “id”. Like I said, it works… sorta… :sigh:
//-- load main buttons --\\
function displayMainButtons() {
var stageWidth = 600;
var main = myXML.firstChild.childNodes;
for (j=0; j<main.length; j++) {
var mainBtnName = main[j].attributes["name"];
var mainBtnId = main[j].attributes["id"];
attachMovie("MainButton", "currentNode"+j, 100+j);
mainButtons = _root["currentNode"+j];
mainButtons._x = stageWidth-j*210;
mainButtons._y = 10;
mainButtons.output = mainBtnName;
mainButtons.thisId = mainBtnId;
mainButtons.mainButton_btn.onRelease = function() {
//trace (this._parent.thisId);
if (this._parent.thisId == 1) {
displayFirstButton();
removeSecondButton();
removeThirdButton();
}
if (this._parent.thisId == 2) {
displaySecondButton();
removeFirstButton();
removeThirdButton();
}
if (this._parent.thisId == 3) {
displayThirdButton();
removeSecondButton();
removeFirstButton();
}
};
}
}
//
//-- load first button --\\
function displayFirstButton() {
var firstButtons = myXML.firstChild.firstChild.childNodes;
for (i=0; i<firstButtons.length; i++) {
var btnName = firstButtons*.attributes["btnName"];
var link = firstButtons*.firstChild.nextSibling.childNodes;
attachMovie("secondBox", "setOne"+i, 200+i);
setOne = _root["setOne"+i];
setOne.firstBox.output = btnName;
setOne.firstBox.myLink = link;
var mc = setOne;
var h = mc._height+5;
mc._y = 10;
mc.targetY = 10+i*h;
mc._x = 5;
mc.onEnterFrame = function() {
var dist = (this.targetY-this._y)*.25;
this._y += dist;
if (Math.abs(dist)<i) {
this._y = this.targetY;
delete this.onEnterFrame;
}
};
}
}
//
//-- Remove first menu --\\
function removeFirstButton() {
var firstSet = myXML.firstChild.firstChild.childNodes;
for (i=0; i<firstSet.length; i++) {
var oneMc = _root["setOne"+i];
baseX = oneMc._alpha;
moveRate = 8;
distance = 0;
oneMc.onEnterFrame = function() {
var alf = (this.baseX+this._y)*.125;
this._alpha -= alf;
this._y += alf;
if (this._alpha<=distance) {
removeMovieClip(this);
//buttonClick = true;
delete this.onEnterFrame;
}
};
}
}
//-- load second buttons --\\
function displaySecondButton() {
var secondButtons = myXML.firstChild.firstChild.nextSibling.childNodes;
for (k=0; k<secondButtons.length; k++) {
var btnName = secondButtons[k].attributes["btnName"];
var link = secondButtons[k].firstChild.nextSibling.childNodes;
attachMovie("secondBox", "setTwo"+k, 250+k);
setTwo = _root["setTwo"+k];
setTwo.firstBox.output = btnName;
setTwo.firstBox.myLink = link;
var mc = setTwo;
var m = mc._height+5;
mc._y = 10;
mc.targetY = 10+k*m;
mc._x = 5;
mc.onEnterFrame = function() {
var dist = (this.targetY-this._y)*.25;
this._y += dist;
if (Math.abs(dist)<k) {
this._y = this.targetY;
delete this.onEnterFrame;
}
};
}
}
//
//-- Remove second menu --\\
function removeSecondButton() {
var second = myXML.firstChild.firstChild.nextSibling.childNodes;
for (k=0; k<second.length; k++) {
var newMc = _root["setTwo"+k];
baseX = newMc._alpha;
moveRate = 8;
distance = 0;
newMc.onEnterFrame = function() {
var alf = (this.baseX+this._y)*.125;
this._alpha -= alf;
this._y += alf;
if (this._alpha<=distance) {
removeMovieClip(this);
//buttonClick = true;
delete this.onEnterFrame;
}
};
}
}
//
//-- Load XML --\\
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = displayMainButtons;
myXML.load("learning.xml");