5 Replies Latest reply on Jan 23, 2010 9:31 AM by jpeto

    button within a button


      I have a button. When you roll over this button a new row of buttons appear (drop down menu). What I would like to know is how to make those Drop Down Menu buttons disappear on Rollout. I'm trying to achieve this by telling the timeline to return to Frame 1 on rollout, but that is not working. I can do this with a single button placed on the stage, but not with several buttons placed within a single button.  (Flash CS4. Action Script 2)


      swf file at http://petoweb.com/telos/filmsBottom-menu.swf


      Flash file and swf attached. Thanks for any help.


        • 1. Re: button within a button
          Ned Murphy Adobe Community Professional & MVP

          I can't open your file, others won't.  What code are you using, and are you really using Button symbols inside other Button symbols (as opposed to movieclips)? (not good)

          • 2. Re: button within a button
            jpeto Level 1

            Thanks Ned, I'll try re-attaching file.

            I tried using buttons inside a movie clip but the roll over effects of the buttons don't work. Are you saying use buttons inside a movie clip or movie clips inside a button? I'll post the code I used if you can't get to this file.


            • 3. Re: button within a button
              Ned Murphy Adobe Community Professional & MVP

              I most likely can't open the file because you're using CS4.  All I was saying (implying) is that buttons inside buttons is an accident waiting to tie you up for hours wondering why it won't work (personal experience due to a client who tried to save money by creating their own buttons).


              What you really oughta do is search Google using "AS2 drop menu tutorial"  That will liklely yield plenty of results to choose from.

              • 4. Re: button within a button
                Harry Kunz Level 4

                If you want to make a new set of buttons pop up, it is best you use actionscript to control appearance of clips on the stage instead of placing them in different frames on the timeline as the currently employed style can get really difficult to maintain and expand in functionality in the future. And i advise you, avoid placing code within a clips such as on(blah2x). It is bad practice. Keep your code centralized on the timeline or an external AS file as much as possible, so you don't end up fumbling for code as your application gets larger in size. In order to gain access to buttons on the stage you can assign "instance names" to the button in the property inspector. Once you have assigned an instance name, say "MyButton" you can assign a function to it like this:


                import mx.utils.Delegate; //Import only once at the beginning of your code


                _root["MyButton"].onRollOver = Delegate.create(this, MyButtonRollOverHandler);

                function MyButtonRollOverHandler():Void


                   trace("MyButton roll over handler");



                By the way, most advanced and expert actionscripters do not use the button symbol anymore but use movieclips instead since they can achieve the same functionality as buttons and are more generic. Keep your extra popup movieclips in the library. You can attach them at runtime but first you need to add a linkage name to the clip in the library by right clicking it within the library and checking the "Export for ActionScript" checkbox, then assign a linkage name say "MyButton_MC". Then you can attach that on the stage like this:


                var mcPopup:MovieClip = _root.attachMovie("MyButton_MC", "MyButton_MC", _root.getNextHighestDepth());

                mcPopup._x = 0; //Put a positive numeric value to position it on the stage's x-axis

                mcPopup._y = 0; //Put a positive numeric value to position it on the stage's y-axis


                You can place that code within your MyButtonRollOverHandler function. That popup should have a bigger hit area controlled by the _xmouse and _ymouse such as the example i've setup for you

                1 person found this helpful
                • 5. Re: button within a button
                  jpeto Level 1

                  Thanks All for the help. Initially I set out to find a quick answer because I'm sick of spending valuable time searching and/or guessing for an easy solution. Alas, both a search and trial and error yielded the results I was looking for. However, it became clear to me after reading hkunz219 post that ActionScripting is the way to go. Only problem is, I'm a WYSWYG guy.

                  I was able to make hkunz219 method work, I just didn't have a good understanding of what I was doing. So, begrudgingly I am going to take an ActionScript course. In the meantime for all you WYSWYGers here is the fla CS4 file I came up with.