Scripting Help
Ok here is what I've got so far...it's pretty basic and what i want to accomplish shouldnt be that hard but for some reason i just cant figure it out.
http://www.hybridart.com/test/flash/
When you click main nav it should show items only from that category in the 2nd nav box. but problem is when you click one it displays them in the number of the array on 2nd menu and then when you change main categories it just keeps adding to them until all items in array are displayed. can someone help me have them list correctly? these are being pulled from an xml file and all the links are being generated dynamically.
here are the source files
http://www.hybridart.com/test/flash/xml_dynamic_button_test.zip
here is actionscript
Code:var numCats:Number = xmlProject.category.catname.length;
var numProjects:Number = xmlProject.project.length;
var ProjectArray:Array = new Array();
var CatArray:Array = new Array();for (var c:Number = 0; c <numCats; c++) {
CatArray[c] = xmlProject.category.catname[c].getValue();
};
//loop to display all categories in category node
for(var j:Number = 0; j < numCats; j++) {
//create button instances
var mc = copyButton.duplicateMovieClip("copy"+j,j+10);
//position button instances
mc._x = 4.5;
mc._y = 67+(j*17);
//update text on button instances with catname node
mc.linktitle.htmlText = xmlProject.category.catname[j].getValue();
//set var to pass into onreleaseFunction
mc.i=j;
mc.onRelease = function() {
//trace(xmlProject.category.catname[this.i].getValue());
currCat = xmlProject.category.catname[this.i].getValue();
_root.gotoAndPlay(3);
}
mc.onRollOver = function() {
this.gotoAndPlay("on");
this.linktitle.textColor = 0xFFFFFF;
}
mc.onRollOut = function() {
this.gotoAndPlay("off");
this.linktitle.textColor = 0x999999;
}
}//Display all Projects by Title Node
for (var i:Number = 0; i < numProjects; i++) {
//show only projects that match clicked category
if (xmlProject.project[i].category.getValue() == currCat){
for (var pa:Number = 0; pa < numProjects; pa++) {
ProjectArray[pa] = xmlProject.project[pa].title.getValue();
trace(i);
}
//ProjectArray.sort();
//create duplicated button instances
var ProjLinksMC = copyButton.duplicateMovieClip("projlinks"+i,i+30);
//position button instances
ProjLinksMC._x = 130;
ProjLinksMC._y = 67+(i*17);
//update text on button instances with title node
ProjLinksMC.linktitle.htmlText = ProjectArray[i];
//ProjLinksMC.linktitle.htmlText = xmlProject.project[i].title.getValue();
//set var to pass inside onRelease function
ProjLinksMC.j=i;
//onRelease function
ProjLinksMC.onRelease = function() {
screenshot.loadMovie(xmlProject.project[this.j].screenshot.getValue());
projText.title.htmlText = xmlProject.project[this.j].projecttitle.getValue();
projText.comment.htmlText = xmlProject.project[this.j].comments.getValue();
}
ProjLinksMC.onRollOver = function() {
this.gotoAndPlay("on");
this.linktitle.textColor = 0xFFFFFF;
}
ProjLinksMC.onRollOut = function() {
this.gotoAndPlay("off");
this.linktitle.textColor = 0x999999;
}
}
}stop();
Thanks.
___________________
"Using a key to gouge expletives on another's vehicle is a sign of trust... and friendship."
- Ignignoc, Aqua Teen Hunger Force
-------------------------------------------------------
[ www.hybridart.com ]
