7 Replies Latest reply on Nov 12, 2009 3:07 PM by Ned Murphy

    Buttons don't work after adding onPress

    frist44

      I have an MC that has a graphic. I have faked buttons for just the over state, so it shows a border around a portion of the graphic. That works fine until I added this to the MC:

       

      this.onPress = function(){
          if (this._currentframe != 1) {

              rewind = true;

          }
      }

       

      The onPress function does what it should do, but the buttons no longer show their over state when I hover over them.

       

      Any ideas?

        • 1. Re: Buttons don't work after adding onPress
          Ned Murphy Adobe Community Professional & MVP

          If you assign mouse event code to the mc and it contains the buttons, the mc's mouse code blocks the buttons from seeing the mouse.

          • 2. Re: Buttons don't work after adding onPress
            frist44 Level 1

            What's the best way around this if I want the exploded MC to be able to shutdown if clicked on, and still see buttons on the MC itself?

            • 3. Re: Buttons don't work after adding onPress
              Ned Murphy Adobe Community Professional & MVP

              It probably depends on the nature of the mc itself.

               

              Could the mc be a button instead?  Then you could have it commanded just as you do and have the over frame stuff show up.

               

              If that's not an option, then make over frame stuff as movieclips and have your onPress function tell them to switch to the frame that displays the over state visual (you may need to employ an onRollOut for the MC to reset those over mc's.

              • 4. Re: Buttons don't work after adding onPress
                frist44 Level 1

                I guess it's sort of a weird situation because I'm using a button, but only because I want a square border to show up.

                 

                So, I have a large graphic that enlarges full screen when the smaller version is clicked. The tween from small to large is the MC. Once large, I have it stop, and the buttons are loaded. Dumbing it down, let's say for example sake, I have each quandrant of the enlarged graphic squared off. So if the user hovers over the top left of the enlarged graphic, a black border is show around that quandrant. And the same for each of the other 3 quadrants. So I'm really just using the button to get the hover effect.

                 

                It seems over board to have to create a movie for all different size squares for each hover effect (afterall, they're not all the same size).

                 

                So does that change anything?

                 

                Thanks!

                • 5. Re: Buttons don't work after adding onPress
                  Ned Murphy Adobe Community Professional & MVP

                  What would be the issue with assigning that code to the buttons instead of the movieclip?  Then you get your quadrant (example) framed display and you get the rewind.  If there are 4 buttons, you just need to code the 4 of them to pull off the rewind bit.

                   

                  btn1.onPress = btn2.onPress = btn3.onPress = btn4.onPress = function(){
                      if (this._currentframe != 1) {

                          rewind = true;

                      }
                  }

                   

                  I'm not sure if that seals the deals or if I'm on some other timeline relative to where you have things, but hopefully you get the idea.

                  1 person found this helpful
                  • 6. Re: Buttons don't work after adding onPress
                    frist44 Level 1

                    That's true. Only problem is there not equal quarters, so some might be circle, and others weird shaped. I guess I could make a button that covers the entire thing with no hover. And then put the border buttons on top of that. And hook the rewind control to all the buttons, so all the area is covered.

                     

                    This is what i originally used for the whole thing:

                     

                    _root.adinstance.onPress = function(){
                        if (_root.adinstance._currentframe != 1) {
                            _root.adinstance.onEnterFrame = function(){
                                 if(_root.adinstance._currentframe != 1){
                                       _root.adinstance.prevFrame();
                                 } else {
                                       delete _root.adinstance.onEnterFrame;
                                 }
                            }
                        }
                    }

                     

                     

                    However, if I try:

                     

                    _root.adinstance.btn1.onPress = function(){
                        if (_root.adinstance._currentframe != 1) {
                            _root.adinstance.onEnterFrame = function(){
                                 if(_root.adinstance._currentframe != 1){
                                       _root.adinstance.prevFrame();
                                 } else {
                                       delete _root.adinstance.onEnterFrame;
                                 }
                            }
                        }
                    }

                     

                    It doesn't work. I tried adding a trace after the onPress of the button and I didn't get anything.

                     

                    Do i have some syntax wrong???

                    • 7. Re: Buttons don't work after adding onPress
                      Ned Murphy Adobe Community Professional & MVP

                      Did you assign the instance name "btn1" to the button (via the properties panel)?  If you didn't get a trace and that button is inside the adinstance mc, then I can only guess that the button isn't named properly.