We help IT Professionals succeed at work.

XML manipulation

hybridart
hybridart asked
on
383 Views
Last Modified: 2008-04-24
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();
Comment
Watch Question

Commented:
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

Author

Commented:
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?
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Vic, thanks for your help...those were both perfect solutions and worked like a charm.

thank you very much!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.