7 Replies Latest reply on May 19, 2008 12:57 PM by robdillon

    Interactive Button Coding

    dpaultaylor Level 1
      Hello

      I'm trying to code a button that when you rollover it, it pops up to display a list of links, ie more buttons. The problem I have is that the containing button is always responding to the click event when I try to click the link/button. You can view the WIP site at http://www.mountainmysteryschool.com and click on the services button, the links never get activated. Thanks
        • 1. Re: Interactive Button Coding
          robdillon Most Valuable Participant
          Make Services a movieClip and then place the buttons inside that clip.
          • 2. Re: Interactive Button Coding
            dpaultaylor Level 1
            Thanks Rob, The services button is already a MovieClip that when you rollover it, it animates into position. It contains the links which are moviclips. I've attached the current code to see if it makes sense. The bit that isn't working is the this.CorporateURL_mc.onPress = etc etc etc. It never needs to react to this event. Thanks in advance
            • 3. Re: Interactive Button Coding
              clbeech Level 3
              yeah this is a common problem - parent MCs that have handlers applied to them 'intercept' event notifications not allowing nested clip event to be 'heard'. what you need to do is use a hitTest within the parents onPress handler to test again the nest clip and see if any of them are being 'hit' or clicked - so to speak - then run the nav from that condition, as in:

              this.onPress = function() {
              if(CorporateURL_mc.hitTest(this._xmouse, this._ymouse, false) {
              trace("it works");
              }
              }
              • 4. Re: Interactive Button Coding
                dpaultaylor Level 1
                Hello

                Thanks for that, I know where you're coming from. Unfortunately I can't get this to work. I've put trace statements in to text the x/y coordinates of the mouse and the traget object and in theory it should work but doesn't. I've attached the code in case I'm missing something obvious. Thanks.
                • 5. Re: Interactive Button Coding
                  clbeech Level 3
                  I'm sorry - the shape flag method requires 'global' coordinates - remove the 'this' from the mouse positions.
                  • 6. Re: Interactive Button Coding
                    dpaultaylor Level 1
                    Hi

                    I'm afraid it still doesn't work. (code attached) the output from the traces seem to indicate that the mouse coordinates do over lap the target object so I'm stuck. I may need to change the technique to do a hit test on the MC that contains the other MCs (the links) so that I don't use onRollOver and then the other MC's should react properly. Thanks
                    • 7. Re: Interactive Button Coding
                      robdillon Most Valuable Participant
                      Here's an example that should get you going. It greatly simplifies the code needed to do what I think that you want to do. You don't really want to put a tween animation inside an enterframe loop. That will just make it go over and over. Just call the tween from the rollover and rollout events. Then you can use one onRelease event to test for each of the buttons that you want to use. I made a single movieClip to act as the object that holds the text buttons, I named the instance "tongue". Then inside that movieClip I placed two instances of another movieClip to act as the text button. I named these "button1" and "button2".