21 Replies Latest reply on Mar 13, 2008 3:57 PM by eranicfetzer

    Drop Down Menu Actionscript

    eranicfetzer
      I have successfully created 4 drop down menus, however, I was wondering if there is a way to use a conditional or boolean statement to make it so only one drop down menu can be seen at a time.
      For example
      if (information.mc._visible = true) {
      } else {(portfolio.mc._visible = false);
      } else {(services.mc._visible = false);
      } else {(toolbox.mc._visible = false);
      }

      Would something like that be possible so that you could only view one drop down menu at a time?
      Any help would be appreciated. Thanks.
        • 1. Re: Drop Down Menu Actionscript
          kglad Adobe Community Professional & MVP
          it's certainly doable but whether your logic is correct depends on your set-up. to test you must correct your syntax:

          to check for equality use the double equals (==) in your if-statement.
          • 2. Re: Drop Down Menu Actionscript
            eranicfetzer Level 1
            Okay I will give that a try.
            Thanks
            • 3. Re: Drop Down Menu Actionscript
              eranicfetzer Level 1
              I tried what you suggested and the other drop down menus still drop down. Is there some other way to accomplish this task?
              • 4. Re: Drop Down Menu Actionscript
                eranicfetzer Level 1
                Here is what my code looks like now. I am not an advanced Actionscript user so I was wondering where I should place this code and if there are any changes that I need to make.
                if (portfolio_mc._visible == true) {
                }else {services_mc._visible = false;
                toolbox_mc._visible = false;
                information_mc._visible = false;
                }

                if (information_mc._visible == true) {
                } else {portfolio_mc._visible = false;
                services_mc._visible = false;
                toolbox_mc._visible = false;
                }

                if (portfolio_mc._visible == true) {
                } else {information_mc._visible = false;
                services_mc._visible = false;
                toolbox_mc._visible = false;
                }

                if (services_mc._visible == true) {
                } else {information_mc._visible = false;
                toolbox_mc._visible = false;
                portfolio_mc._visible = false;
                }
                • 5. Re: Drop Down Menu Actionscript
                  kglad Adobe Community Professional & MVP
                  that doesn't look like something you would want to do. you're checking if each mc's _visible property is false and, if so, assign the the other _visible properties to be false.

                  you aren't doing anything when a _visible property is true.
                  • 6. Re: Drop Down Menu Actionscript
                    eranicfetzer Level 1
                    So, if I can't do it using the visible property, how can I make it so that only one can either be played or seen at a given time? I imagine that there is something that can be done using actionscript besides:
                    on (rollOut) {
                    gotoAndPlay("collapsedstate");
                    }
                    Is there another method?
                    • 7. Re: Drop Down Menu Actionscript
                      kglad Adobe Community Professional & MVP
                      i didn't say you couldn't do it with the visible property. i just said you're not doing anything useful with that code. you need to rethink your logic.

                      if you mean to check if one of the movieclip's is visible, then the others should not be visible, change your code.
                      • 8. Re: Drop Down Menu Actionscript
                        eranicfetzer Level 1
                        Sorry, I am sure that this is a dumb question, but how would I make it so that if one of the movieclips is visible then the others wouldn't be?
                        if (portfolio_mc._visible == false) {
                        }else {services_mc._visible = true;
                        toolbox_mc._visible = true;
                        information_mc._visible = true;
                        }
                        Or would it require a change in the coding altogether?
                        • 10. Drop Down Menu Actionscript
                          eranicfetzer Level 1
                          After reviewing my code I have come up with a partial solution. I have made it so that only one drop down menu at a time appears when I rollover it with the following:

                          header_mc.portfolio_mc.onRollOver = function() {
                          _root.header_mc.portfolio_mc.gotoAndPlay("Portfolioexpand");
                          _root.header_mc.services_mc.gotoAndStop("collapsed");
                          _root.header_mc.information_mc.gotoAndStop("Infocollapse");
                          _root.header_mc.toolbox_mc.gotoAndStop("ToolBcollapse");
                          }

                          However, since I made the movie clip have a rollover function I cannot get my buttons to go to the appropriate URL. I have tried making it part of the function process, with code such as the following
                          header_mc.portfolio_mc.portfoliobtn.onRelease = function() {
                          getURL(" http://www.myURL.com", "_self");
                          }

                          I was wondering if it doesn't work because the movie clip rollover function is first or if there is another way to solve this problem.
                          • 11. Re: Drop Down Menu Actionscript
                            kglad Adobe Community Professional & MVP
                            if you attach any mouse handlers to a parent movieclip that parent will intercept all mouse events so the child movieclips cannot respond.
                            • 12. Re: Drop Down Menu Actionscript
                              eranicfetzer Level 1
                              So are you suggesting that I change the code to the following:

                              header_mc.portfolio_mc.onRollOver = function() {
                              _parent.header_mc.portfolio_mc.gotoAndPlay("Portfolioexpand");
                              _parent.header_mc.services_mc.gotoAndStop("collapsed");
                              _parent.header_mc.information_mc.gotoAndStop("Infocollapse");
                              _parent.header_mc.toolbox_mc.gotoAndStop("ToolBcollapse");
                              }

                              Or something else?
                              • 13. Re: Drop Down Menu Actionscript
                                kglad Adobe Community Professional & MVP
                                i didn't make any suggestion. i just supplied the reason your child mouse handlers no longer work.

                                how you want to proceed is up to you. you can remove the parent mouse handler and use something else. or you can leave the parent mouse handler and use something other than mouse handlers for the child movieclips (like a loop and hittest).
                                • 14. Re: Drop Down Menu Actionscript
                                  eranicfetzer Level 1
                                  How could you use a loop or a hittest, I am really a beginner when it comes to Actionscript. Removing the parent mouse handler would be the following correct?
                                  header_mc.portfolio_mc.gotoAndPlay("Portfolioexpand");
                                  How could I get around this problem? All I really want to do is make it so that you can only access one drop down menu at a time.
                                  • 15. Re: Drop Down Menu Actionscript
                                    kglad Adobe Community Professional & MVP
                                    your header_mc.portfolio_mc.goto method is not related to removing mouse handlers. your

                                    header_mc.portfolio_mc.onRollOver = ...

                                    is the parent mouse handler that could be part of the solution. the other parts would be ensuring there are no other mouse handlers for head_mc.portfolio_mc and creating your loop and checking for a hitTest. that could be something like:

                                    • 16. Re: Drop Down Menu Actionscript
                                      eranicfetzer Level 1
                                      I tried implementing a hitTest into my code and it just made the movie clip blip in and out repeatedly. How would you make a loop? I apologize for troubling you all with rather basic questions, but I definitely need the help.
                                      • 17. Re: Drop Down Menu Actionscript
                                        kglad Adobe Community Professional & MVP
                                        the onMouseMove causes that hitTest to repeatedly execute so no other looping is needed.

                                        you must remove all mouse handlers attached to header_mc.portfolio_mc. if you only define the positive hitTest arm of that conditional, you won't have any "rollout" behavior so you shouldn't see anything "blip in and out".
                                        • 18. Re: Drop Down Menu Actionscript
                                          eranicfetzer Level 1
                                          I used a tutorial and learned of the following actionscript:

                                          portfoliobtn.onRollOver=function(){
                                          if(menuOpen=="portfolio"){
                                          null;
                                          }
                                          else if(menuOpen=="close" || menuOpen=="services" || menuOpen=="information" || menuOpen=="toolbox"){
                                          isitOpen();
                                          portfoliomc.gotoAndPlay("show");
                                          }
                                          }

                                          servicesbtn.onRollOver=function(){
                                          if(menuOpen=="services"){
                                          null;
                                          }
                                          else if(menuOpen=="close" || menuOpen=="portfolio" || menuOpen=="information" || menuOpen=="toolbox"){
                                          isitOpen();
                                          servicesmc.gotoAndPlay("show");
                                          }
                                          }

                                          informationbtn.onRollOver=function(){
                                          if(menuOpen=="information"){
                                          null;
                                          }
                                          else if(menuOpen=="close" || menuOpen=="portfolio" || menuOpen=="services" || menuOpen=="toolbox"){
                                          isitOpen();
                                          informationmc.gotoAndPlay("show");
                                          }
                                          }

                                          toolboxbtn.onRollOver=function(){
                                          if(menuOpen=="toolbox"){
                                          null;
                                          }
                                          else if(menuOpen=="close" || menuOpen=="portfolio" || menuOpen=="services" || menuOpen=="information"){
                                          isitOpen();
                                          toolboxmc.gotoAndPlay("show");
                                          }
                                          }

                                          var menuOpen:String="close";
                                          function isitOpen(){
                                          if(menuOpen=="services"){
                                          menuOpen="close";
                                          servicesmc.gotoAndPlay("hide");
                                          }
                                          else if(menuOpen=="portfolio"){
                                          menuOpen="close";
                                          portfoliomc.gotoAndPlay("hide");
                                          }
                                          else if(menuOpen=="information"){
                                          menuOpen="close";
                                          informationmc.gotoAndPlay("hide");
                                          }
                                          else if(menuOpen=="toolbox"){
                                          menuOpen="close";
                                          toolboxmc.gotoAndPlay("hide");
                                          }
                                          }
                                          homebtn.onRollOver=function(){
                                          isitOpen();
                                          }
                                          contactbtn.onRollOver=function(){
                                          isitOpen();
                                          }

                                          My question is how would I make this work within my header_mc. If I take it out of the header_mc it works perfectly, however, it would be nice if I could contain all of the items inside of a movie clip.
                                          • 19. Re: Drop Down Menu Actionscript
                                            eranicfetzer Level 1
                                            I have tried making the paths header_mc.portofoliobtn and it seems like the functions do not work, can you have actionscript apply solely to a movieclip?
                                            • 20. Re: Drop Down Menu Actionscript
                                              eranicfetzer Level 1
                                              If anyone wants to accomplish a similar task please go to www.actionscript.org and check out their Flash tutorials.
                                              • 21. Re: Drop Down Menu Actionscript
                                                eranicfetzer Level 1
                                                If anyone wants to accomplish a similar task please go to www.actionscript.org and check out their Flash tutorials.