Link to home
Start Free TrialLog in
Avatar of hybridart
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.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();
Avatar of victmo
victmo

Hello,

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].category.getValue() == currCat){
         .
         .
         .
      }else{
        this["projlinks"+i].unloadMovie();  <-- ADD THIS!!! if NOT == currCat we unload it
      }

Hope it helps

Vic
Avatar of hybridart

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?
ASKER CERTIFIED SOLUTION
Avatar of victmo
victmo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Vic, thanks for your help...those were both perfect solutions and worked like a charm.

thank you very much!