12 Replies Latest reply on Apr 14, 2010 5:47 PM by spirito78

    XML menu

    spirito78

      Hello,

      I am trying to use the (frame function). I am having a problem with the action script.  It's not going to the next frame.

      Can someone please help me out on this. It sounds simple but I am missing something.

       

       

      Thanks,

      Tom

       

      Actionscript

      Code menu_mc.onItemClick= function(node:XMLNode, level:Number)

      { my_movie_clip.gotoAndStop(Number(node.attributes  .frame))

       

       

       

       

      XML DATA:

      <menu>
      <item label="Home" frame="1"/>
      <item label="About Us" frame="2" />
      <item label="Cosmetic Procedures" />
      <item label="Cosmetic Surgery" />
      <item label="Dermatological Services" />
      <item label="New Patient Forms" />
      <item label="Medical grade Products" />
      <item label="Contact" />
      <item label="Monthly Specials" />
      </menu>

        • 1. Re: XML menu
          kglad Adobe Community Professional & MVP

          show your code that loads and parses your xml.

          • 2. Re: XML menu
            spirito78 Level 1

            Stage.scaleMode = "noScale";
            Stage.showMenu = false;
            Stage.align = "TL";
            // CLICK HANDLER FUNCTION
            menu_mc.onItemClick = function(node:XMLNode, level:Number) {
                res_txt.text = "Label> "+node.attributes.label+" | Menu item level> "+level;
            };
            // LOAD XML AND GENERATE MENU
            var xob:XML = new XML();
            xob.ignoreWhite = true;
            xob.onLoad = function(s) {
                if (!s) {
                    trace("Error loading xml file !");
                    return;
                }
                menu_mc.data = this.firstChild;
            };
            xob.load("data.xml");

            • 3. Re: XML menu
              kglad Adobe Community Professional & MVP

              node is undefined in your function.  and you have duplicate onItemClick() methods.

              • 4. Re: XML menu
                spirito78 Level 1

                kglad wrote:

                 

                node is undefined in your function.  and you have duplicate onItemClick() methods.

                        kglad,

                        Could you give me example. Is it something like this.

                 

                 

                Code menu_mc.onItemClick= function(node:XMLNode, level:Number)

                { my_movie_clip.gotoAndStop(Number(node.attributes  .frame))

                • 5. Re: XML menu
                  kglad Adobe Community Professional & MVP

                  you should be doing something like:

                   



                  Stage.scaleMode = "noScale";
                  Stage.showMenu = false;
                  Stage.align = "TL";
                  // CLICK HANDLER FUNCTION
                  menu_mc.onRelease = function() {

                  // i have no idea what level is
                      res_txt.text = "Label> "+xob.firstChild.childNodes[0].attributes.label+" | Menu item level> "+level;
                  };
                  // LOAD XML AND GENERATE MENU
                  var xob:XML = new XML();
                  xob.ignoreWhite = true;
                  xob.onLoad = function(s) {
                      if (!s) {
                          trace("Error loading xml file !");
                          return;
                      }
                      menu_mc.data = this.firstChild;
                  };
                  xob.load("data.xml");

                  • 6. Re: XML menu
                    spirito78 Level 1

                    Sorry it didn't work. It won't  advance to the next fame.

                    • 7. Re: XML menu
                      kglad Adobe Community Professional & MVP

                      are you still using that duplicate function code?

                      • 8. Re: XML menu
                        spirito78 Level 1

                        this is what I have

                         

                        Stage.scaleMode = "noScale";
                        Stage.showMenu = false;
                        Stage.align = "TL";
                        // CLICK HANDLER FUNCTION

                         

                        menu_mc.onItemClick = function(node:XMLNode, level:Number) {
                            res_txt.text = "Label> "+node.attributes.label+" | Menu item level> "+level;
                        };

                         


                        menu_mc.onItemClick= function(node:XMLNode, level:Number){
                        _root.home_mc.gotoAndStop(Number(node.attributes.frame));
                        }

                        menu_mc.onItemClick= function(node:XMLNode, level:Number){
                        _root.about_us_mc.gotoAndStop(Number(node.attributes.frame));
                        }

                         

                        // LOAD XML AND GENERATE MENU
                        var xob:XML = new XML();
                        xob.ignoreWhite = true;
                        xob.onLoad = function(s) {
                            if (!s) {
                                trace("Error loading xml file !");
                                return;
                            }
                            menu_mc.data = this.firstChild;
                        };
                        xob.load("data.xml");

                        • 9. Re: XML menu
                          kglad Adobe Community Professional & MVP

                          that code shows you've understood and/or read nothing that i've posted.

                          1 person found this helpful
                          • 10. Re: XML menu
                            spirito78 Level 1

                            Here is my fla file. I don't understand I added onRelease and the 

                            highlight does work so I put the code back

                            • 11. Re: XML menu
                              robdillon Most Valuable Participant

                              I found this link to a very similar problem: http://forum.oxylusflash.com/2-levels-accordion-menu/3197-links-not-working-no-idea-why.ht ml

                               

                              Have a read through that and see if it helps to solve the problem.

                              • 12. Re: XML menu
                                spirito78 Level 1

                                Everyone thanks I figure it out