8 Replies Latest reply on Aug 10, 2011 9:53 AM by Ned Murphy

    Flash Menu: Unable to get links to work

    Theforgotten7

      I purchased a website template that has some flash in it however the auther of the template lacked to include instructions and seemed to have left it unfinished (The links don't work, of course).

       

      I am no where near as good at flash as I would like to be and I can't seem to figure it out. I have looked at another thread which seems to have the exact same problem as me (possibly the same template) but I can't seem to locate the actionscript he talks about: http://forums.adobe.com/message/3692512

       

      Here is my current menu.as code:

       

      var feed_xml:XML = new XML();
      feed_xml.ignoreWhite = true;
      xml_loader._xscale = 0;
      feed_xml.load("menu.xml");
      feed_xml.onLoad = function(success) {
          import mx.xpath.XPathAPI;
          _global.menu_array = XPathAPI.selectNodeList(feed_xml.firstChild, "/menu/entry");
          for (i=0; i<menu_array.length; i++) {
              _global.menu_array[i].label = menu_array[i].attributes.label;
              _global.menu_array[i].url = menu_array[i].attributes.url;
          }
          _root.movie_loading();
      };

       

      my XML (link labels and etc)

      <menu>
          <entry label="HOME" url="index.html" />
          <entry label="ABOUT PARKER" url="parker.html" />
          <entry label="ABOUT US" url="about-us.html" />
          <entry label="BUY/SELL HOMES" url="sales.html" />
          <entry label="RENT HOMES" url="rents.html" />
          <entry label="CONTACT US" url="contact-us.htm;" />
      </menu>

       

      Notice that nothing there helps me with clickable links :\

       

      I cannot find the actionscript that deals with onRollOver actions if anyone could help me I would be absolutly ecstatic.

       

      Download source files: http://dl.dropbox.com/u/32753780/source.rar

        • 1. Re: Flash Menu: Unable to get links to work
          Ned Murphy Adobe Community Professional & MVP

          You should try looking in the Flash fla file for a function on the main timeline called _root.movie_loading();  You might find the xml for the links being assigned there.  In case you don't realize it, since you said "nothing there helps me with clickable links" the xml contains what appears to be both the labels for the links and the web pages for the links.  So that should be all you might need to edit to link to your pages.

          1 person found this helpful
          • 2. Re: Flash Menu: Unable to get links to work
            Theforgotten7 Level 1

            Nothing in the .fla file has anything linking the url code from the xml file to the button's hyperlink actions. Also if you look I already have that area filled in with what I want it to be. I will look for that linking you mentioned but while looking through all of the actionscript I have yet to find anything relating to button commands.

             

            I found this linking the menu.as file to the flash file but I couldn't find anything relating to the xml file (If im not mistaken the menu.as file does that.

             

            #include "menu.as"
            var my_cm:ContextMenu = new ContextMenu ();
            my_cm.hideBuiltInItems ();
            my_cm.builtInItems.print = true;
            this.menu = my_cm;
            stop ();
            movie_loading = function ()
            {
                //goto frame 2 where flash movie initialize or preloader function start
                gotoAndStop (2);
            };

            ------ Edit Line -----

             

            I was going through the source again when I noticed this text at first I thought it was gibberish but then I realized it was actually russain (upon translation) I found that it said Testing release, so I'm guessing this is my button release code here (included the russian text)

             

            //отработка релеаза$$$
            function rel()
            {
                sel.gotoAndPlay("s2");
               
            }

             

            Only now I'm confused as to what to put in there to make it go to the links provided by my XML file.

            • 3. Re: Flash Menu: Unable to get links to work
              Ned Murphy Adobe Community Professional & MVP

              Have you looked in frame 2 to see what code exists there that might be related?  Are the buttons manually planted on the stage or would it appear they are created dynamcially?  If they are on the stage, try selecting one of them and you might find the code attached directly to the button (a poor AS2 practice, partly because it has made your finding it difficult)... that's where template designers more often tend to plant button code.

              • 4. Re: Flash Menu: Unable to get links to work
                Theforgotten7 Level 1

                Please read the above again.

                 

                The code was hidden in a random frame under some russain comment text. I've tried entering in the following code *found in the other help thread*:

                function rel()
                {
                    sel.gotoAndPlay("s2");

                    var temp:Number=Number(String(this._name).charAt(1));
                        getURL(_global.menu_array[temp].url,"_blank");

                   
                }

                 

                howerver all that got me was this page: http://awesomescreenshot.com/05dibj7e5

                • 5. Re: Flash Menu: Unable to get links to work
                  Ned Murphy Adobe Community Professional & MVP

                  Why should I reead the above again? It offered nothing relative to any code that would link to a web page.  The code you show now does. (If you think I have looked at your file, I will not be doing that)

                   

                  In your first post, there is a section of code that creates the link between the urls and the buttons that use it

                   

                      for (i=0; i<menu_array.length; i++) {
                          _global.menu_array[i].label = menu_array[i].attributes.label;
                          _global.menu_array[i].url = menu_array[i].attributes.url;
                      }

                   

                  That code is taking the xml data and assigning it to an array named menu_array, of which the url portion is the link

                   

                  If you look at the code you just showed, that code makes use of the menu_array that holds the link data to assign to a getURL function call which is what will execute linking to the web page.

                   

                  function rel()
                  {
                      sel.gotoAndPlay("s2");

                   

                     //. get a number (index) from the button instance name's second character

                      var temp:Number=Number(String(this._name).charAt(1));


                     // use that number to get the url property from the menu_array object residing at that index

                      getURL(_global.menu_array[temp].url,"_blank");
                     
                  }

                   

                  So chances are your buttons are named something like "b0", "b1", etc...

                  1 person found this helpful
                  • 6. Re: Flash Menu: Unable to get links to work
                    Theforgotten7 Level 1

                    Because you were asking if I have located the release code.

                    --

                     

                    I didn't expect you too seeing as how you are neither paid for this nor are obligated to. I just know that some people would rather do that to provide faster support and have a better understanding for the problem.

                    --

                     

                    Your hypothesis on the button names would seem to be correct seeing this portion of the code a handful of lines above the release code:

                     

                    function buts()
                    {
                        for (i=0; i<_global.menu_array.length; i++)
                        {
                            this.attachMovie("but", "b"+i, this.getNextHighestDepth());
                        }
                    }

                     

                    Going off of that I tried

                     

                    function rel()
                    {
                        sel.gotoAndPlay("s2");

                        var temp:Number=Number(String(this._name).charAt(1));

                        getURL(_global.menu_array["b"+temp].url,"_blank");
                       
                    }

                     

                    Which seemed to work out perfectly, thank you a lot for your guidence. I've had very little sleep so I doubt I would have found that simple mistake on my own haha.

                    • 7. Re: Flash Menu: Unable to get links to work
                      Theforgotten7 Level 1

                      Thank again for all the support ^^

                      • 8. Re: Flash Menu: Unable to get links to work
                        Ned Murphy Adobe Community Professional & MVP

                        I don't see how changing the array index to be a string will work... ["b"+temp]

                         

                        The line before is extracting the number from the button's name so that it can be used to target the element of the array.  The line before that wouldn't be necessary if you were using the name of the button.  The getURL line could use the name directly...

                         

                        getURL(_global.menu_array[this._name].url,"_blank");...

                         

                        but in any case, the use of the button's name as an array index will not work.  Chances are your template was designed to work properly based on what you've shown.  If you've changed things within the file it is not likely that you needed to.  The xml file should be all you need to change.