hybridart
asked on
XML manipulation
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
var numCats:Number = xmlProject.category.catnam e.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.catnam e[c].getVa lue();
};
//loop to display all categories in category node
for(var j:Number = 0; j < numCats; j++) {
//create button instances
var mc = copyButton.duplicateMovieC lip("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.catnam e[j].getVa lue();
//set var to pass into onreleaseFunction
mc.i=j;
mc.onRelease = function() {
//trace(xmlProject.categor y.catname[ this.i].ge tValue());
currCat = xmlProject.category.catnam e[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].cat egory.getV alue() == currCat){
for (var pa:Number = 0; pa < numProjects; pa++) {
ProjectArray[pa] = xmlProject.project[pa].tit le.getValu e();
trace(i);
}
//ProjectArray.sort();
//create duplicated button instances
var ProjLinksMC = copyButton.duplicateMovieC lip("projl inks"+i,i+ 30);
//position button instances
ProjLinksMC._x = 130;
ProjLinksMC._y = 67+(i*17);
//update text on button instances with title node
ProjLinksMC.linktitle.html Text = ProjectArray[i];
//ProjLinksMC.linktitle.ht mlText = xmlProject.project[i].titl e.getValue ();
//set var to pass inside onRelease function
ProjLinksMC.j=i;
//onRelease function
ProjLinksMC.onRelease = function() {
screenshot.loadMovie(xmlPr oject.proj ect[this.j ].screensh ot.getValu e());
projText.title.htmlText = xmlProject.project[this.j] .projectti tle.getVal ue();
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();
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
var numCats:Number = xmlProject.category.catnam
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.catnam
};
//loop to display all categories in category node
for(var j:Number = 0; j < numCats; j++) {
//create button instances
var mc = copyButton.duplicateMovieC
//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.catnam
//set var to pass into onreleaseFunction
mc.i=j;
mc.onRelease = function() {
//trace(xmlProject.categor
currCat = xmlProject.category.catnam
_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].cat
for (var pa:Number = 0; pa < numProjects; pa++) {
ProjectArray[pa] = xmlProject.project[pa].tit
trace(i);
}
//ProjectArray.sort();
//create duplicated button instances
var ProjLinksMC = copyButton.duplicateMovieC
//position button instances
ProjLinksMC._x = 130;
ProjLinksMC._y = 67+(i*17);
//update text on button instances with title node
ProjLinksMC.linktitle.html
//ProjLinksMC.linktitle.ht
//set var to pass inside onRelease function
ProjLinksMC.j=i;
//onRelease function
ProjLinksMC.onRelease = function() {
screenshot.loadMovie(xmlPr
projText.title.htmlText = xmlProject.project[this.j]
projText.comment.htmlText = xmlProject.project[this.j]
}
ProjLinksMC.onRollOver = function() {
this.gotoAndPlay("on");
this.linktitle.textColor = 0xFFFFFF;
}
ProjLinksMC.onRollOut = function() {
this.gotoAndPlay("off");
this.linktitle.textColor = 0x999999;
}
}
}
stop();
ASKER
victmo, awesome ok that got the 2nd movie clip to unload and show only those items...but they still show spaced out...like based on what number they are located in the array. for instance when you click multimedia link it shows 2 items on 2nd nav...and they display like this.
-------
(line break)
link 1
(line break)
(line break)
(line break)
link 2
-------
instead of showing like this
-------
link1
link2
(line break)
(line break)
(line break)
(line break)
-------
make sense? how do i get the 2nd nav to list like the way 1st nav is displayed?
-------
(line break)
link 1
(line break)
(line break)
(line break)
link 2
-------
instead of showing like this
-------
link1
link2
(line break)
(line break)
(line break)
(line break)
-------
make sense? how do i get the 2nd nav to list like the way 1st nav is displayed?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Vic, thanks for your help...those were both perfect solutions and worked like a charm.
thank you very much!
thank you very much!
You need to unload the movieclips you dont wanna use from the second list. To do so try the following:
//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].cat
.
.
.
}else{
this["projlinks"+i].unload
}
Hope it helps
Vic