13 Replies Latest reply on May 30, 2009 7:57 PM by mentlity

    Button overlap problem

    mentlity Level 1

      I have a set of navigation buttons that go to frames and open different .swfs

       

      The Commercial button and Music Video button are two movieclips with buttons inside

       

      Commercial clip has 5 buttons that stretch out 600 pxls across

       

      Music Video button has 2 buttons that stretch about 150 pxls across

       

      Problem:

      mouseover Commercial and you will see the secondary buttons appear within the mc (disregard links)

       

      if I mouseover Music Video that button clip opens right on top of the Commercail button

       

      only difference between these two buttons are:

       

      Commercial has on rollover in hit state of commercial text

      and

      on rollout in an invisible button on top of background length

       

      while

       

      Music Video has on rollover in hit state of Music Video text

      and

      on rollout in an invisible button across entire stage (this was the original way I had both)

       

      I need to know the best way to have both of these mc/ buttons co exist side by side without interfering with the other.

       

      Eventually all the navigation will have the same mc / buttons as all will link to specific swfs.

       

      .fla is in the attached

       

       

      You guys are gods and your help is so important and so appreciated as I try to find actionscript to use here but it seems no two tasks are the same.

       

      any help?

        • 1. Re: Button overlap problem
          Ned Murphy Adobe Community Professional & MVP

          You'll need to find some other way of presenting your case.  Your attachments are lost somewhere and your description is not clear (to me).

          • 2. Re: Button overlap problem
            mentlity Level 1

            Thanks for taking the time, heres what I need to do.

             

            I have two movieclips (acting as buttons)

            1 has  5 buttons inside (visible on rollover state)

             

            rollover state opens mc from 150 to 600 pxls wide (its a horizontal menu)

             

            2nd clip is built the same way but only has 2 buttons inside

             

            both clips sit side by side - used for navigation

             

             

             

            when you rollover the first clip it opens fine

             

            when you rollout I used an invisible btn that is on top of the over state seems to work OK

             

            when you rollover the second clip it opens fine

             

            when you rollout I used an invisible btn that is the size of the stage seems to work OK

             

            problem:

             

            when clip one is open if I roll the mouse over clip two clip one remains open and the both clips are on top of each other.

             

            the fla in the attched has the parts inside.

             

            thx again

            • 3. Re: Button overlap problem
              mentlity Level 1

              I seemed to have figured a way to do this, I ripped the buttons apart and did the following, made new buttons. Where btn hit state is only the text and it loads the actual movieclip.

               

              commercial_btn.onRollOver = function(){
              attachMovie("commddnav_mc","commddnav_mc",0,{_x:283.9,_y:193});
              }

               

              documentary_btn.onRollOver = function(){
              attachMovie("documentary_ddnav_mc","documentary_ddnav_mc",0,{_x:500,_y:193});
              }

               

              mvideo_btn.onRollOver = function(){
              attachMovie("musicvideo_dd_nav_mc","musicvideo_dd_nav_mc",0,{_x:400,_y:193});
              }

               

              this works as you mouseover each button the new clip appears unloading the previous.

               

              Now this causes another problem:

               

              the last clip that was rolled over remains visible, I cannot have that. I need the last clip to unload without using a rollOut.

               

              Reason I cannot use a simple OnRollOut for these mc's is the hitstates of the mc buttons are the length of the text  in the button only I cannot make the hit state the size of the whole clip underneath as it will only cause the overlapping problem again, follow?

               

               

              only thing I can think of is

               

              Can  I do the following in each btn

               

              if the mouse _x _y is anywhere outside of the movieclip it unloads it ?

               

              Could I do for each and so when you go outside of each clip it unloads?

               

              sorry for the confusion I hope I'm clear.

              • 4. Re: Button overlap problem
                Ned Murphy Adobe Community Professional & MVP

                Here's the neat thing about solving problems in actionscript and Flash design... if you have an idea of how to solve something, you can try it.  I'm not being sarcastic in saying that... it's often how I end up with a working solution... it may not be the leanest or sleakest approach, but if it works, it's not gonna make a difference to the viewer.

                 

                What you described may be feasible, so you'll need to continuously monitor the mouse position relative to the limits you set for each one.

                 

                It's possible there would be a simpler solution going the old way you had it, or with what you have now, but without seeing it, I can't tell.  But like I said, if you think of a possible solution, try it.  They will usually become leaner as you go thru the trial and error phase.

                • 5. Re: Button overlap problem
                  mentlity Level 1

                  Trying to figure out the correct AS 2.0  to remove  a Movieclip  that is on the stage. The clip was put on the stage using
                  attachMovie,

                   

                  I need to remove the clip when the mouse goes outside of the movieclip boundry's x and y coordinates  I need it to
                  activate removeMovieClip

                   

                  any help?

                   

                  this should solve my whole problem .

                   

                  A bit tricky for me, any help?

                  • 6. Re: Button overlap problem
                    Ned Murphy Adobe Community Professional & MVP

                    If you look at the removeMovieClip method in the help docs, there is an example there which includes attaching and removing a movieclip.  In my own experience, it can be confusing to get the targeting correct, so it may take some trial and error.  BAsed on what I think I'm seeing in that example...

                     

                    var attachedMovie = this.attachMovie(...etc...);

                     

                    attachedMovie.removeMovieClip();

                    • 7. Re: Button overlap problem
                      mentlity Level 1

                      First of all the correct terms in Flash that I need to do is "Object removal relative to mouse position" and "Set Property" I was looking for more info and found a tutorial for "Object Movement Relative To Mouse Position"  but the concept is different . In the attached file is a simplified version of what I need to do.

                       

                      Two buttons with On RollOver "attachMovie"

                      (when you roll over one the only way to remove is roll over the other)

                       

                      NOW , if you look at the .fla you will see that I cannot use a rollOut on any of these buttons because the hit state of the button only covers the text area of it. I need a solution to remove which ever clip was rolled over last. After hours of searching I can only come up with one solution, use RemoveMovieClip.

                       

                      My goal here is to be able to always have the navigation buttons visible and only have 1 movieclip visible when you roll over a button.

                       

                      If I took the properties of each mc, lets say mc1 is _x 600 _y 50 and mc2 is _x250 _y 50

                       

                      then I need to tell Flash that, if you roll the mouse OUTSIDE the mc properties activate RemoveMovieClip .

                       

                      I tried putting together the code but I do not know enough about AS to get it right. I know I should be using the if statement correct?

                       

                      hereis the code I used to add the btns / mcs to the stage

                       

                      load_btn1.onRollOver = function(){
                      attachMovie("commddnav_mc","commddnav_mc",0,{_x:200,_y:200});
                      }

                       

                      load_btn2.onRollOver = function(){
                      attachMovie("documentary_ddnav_mc","documentary_ddnav_mc",0,{_x:400,_y:200});
                      }

                       

                      now I just need the code to remove each AFTER they are rolled on.

                       

                      Any help here?

                      • 8. Re: Button overlap problem
                        mentlity Level 1

                        Still stuck here, I did manage to get the correct terms for what I need to achieve.

                        "Object Removing Relative To Mouse Position" and "Set Property"

                         

                        Simple .fla is in the attached to see exactly what I mean as I just need someone to show me the correct actionscript for this.

                         

                        What I need to do,

                         

                        Remove last rolled over clip from stage using RemoveMovieClip

                         

                        The concept here is there are two menus (1 in each clip)

                        you can select any button in both menus

                         

                        I originally had an overlap problem but corrected by using attachMovie on both buttons so the other button automatically is removed once you rollover another

                         

                        but now the last clip rolled over always remains on the stage, I do not want this

                         

                        I want each clip to disappear once you rollaway from it.

                         

                        Only way I see is to do by mouse position

                         

                        activated when you roll OUTSIDE the last rolled over mc's boundries so I need to tell Flash

                         

                        in each button

                         

                        if mc (relative to button) is playing

                        use RemoveMovieClip

                        when

                        mouse rolls outside of mc's boundries.

                         

                        Something like this inside actions layer of each mc?

                         

                        if (_root._xmouse>=200) {
                        _level0.commddnav_mc._x = (_level0.commddnav_mc_x???);
                        _level0.commddnav_mc._y = (_level0.commddnav_mc_y???);

                        } else {

                        RemoveMovieClip???????

                         

                        anybody?

                        • 9. Re: Button overlap problem
                          Ned Murphy Adobe Community Professional & MVP

                          As I already mentioned, if you want to use removeMovieClip based on the mouse position, you will need to continuously monitor the position of the mouse while the movie is present.

                           

                          You can probably use onEnterFrame monitoring to accomplish that, or even a movieclip that contstantly moves between frames to check the positions.  Since this checking would be relative to the movieclip, it is may be easiest to incorprate it into the movieclip.  If the x and y values of the mouse exceed x and y values for a given clip, you trigger the removeMovieClip call.  So within the movieclip, something like the following is what you might try...

                           

                          this.onEnterFrame = function(){

                               if((_root._xmouse < this._x || _root._xmouse > this._y+this._width) && (_root._ymouse < this._y || _root._ymouse > this._y+this._height){

                           

                                    this.removeMovieClip();

                           

                               }

                          }

                          • 10. Re: Button overlap problem
                            mentlity Level 1

                            Ah!!!! Now I see !!

                             

                            you are absolutely correct, this is what I want to do .

                             

                            this.onEnterFrame = function(){

                                  if((_root._xmouse < this._x -159.9 root.xmouse > this._y

                            +this._width) && (_root._ymouse < this._y -110.9 root.ymouse > 

                            this._y+this._height))

                             

                                       this.removeMovieClip();

                             

                                  }

                             

                            }

                                  

                              I added the code and set the mc x properties but I get an 

                            actionscript error

                             

                            frame 1 line 2        ')' expected

                             

                             

                            where do I put the )   ???

                            • 11. Re: Button overlap problem
                              mentlity Level 1

                              Sorry but I see that the "||' statements are Bitwise operators so I 

                              removed the actual x and y coordinates from the code so it now looks 

                              like this

                               

                              this.onEnterFrame = function(){

                                    if((_root._xmouse < this._x || root.xmouse > this._y

                              +this._width) && (_root._ymouse < this._y || root.ymouse > this._y

                              +this._height){

                               

                                         this.removeMovieClip();

                               

                                    }

                              }

                               

                               

                              but I still get an actionscript error

                               

                              Line 2      ')' expected

                               

                              sorry for the confusion

                              • 12. Re: Button overlap problem
                                Ned Murphy Adobe Community Professional & MVP

                                My code had a couple of errors in it, one of which the error message is telling you about.  There's a parenthesis missing at the end of that conditional line, and in the first conditional it should have had this._x rather than this._y

                                 

                                 

                                if((_root._xmouse < this._x || _root._xmouse > this._x+this._width) && (_root._ymouse < this._y || _root._ymouse > this._y+this._height)){

                                • 13. Re: Button overlap problem
                                  mentlity Level 1

                                  First of all thanks for taking the time to give me the code, the bad news for me is now with the code inside the movieclip the movieclip never appears. I would think that is because the mouse is outside the boundry of the clip and has to be to activate the button on top which is supposed to activate the attachMovie command on rollOver.

                                   

                                  In the attached is the fla with the code.

                                   

                                  So I go from one problem to another.

                                   

                                  Now what?