5 Replies Latest reply on Mar 26, 2007 11:02 AM by kglad

    MC with 4 button states

    jl2000 Level 1
      Hi -
      I' m using an MC for a button. It has 4 states, up, over, down and hold...10 frames apart on the timeline.
      The first onRelease brings the mc to the "hold" state. The next on Release would return it to the "up" state. The problem arises when the onRollOver occurs. The mc's timeline jumps to the "over" state so I can't direct it with something like "if on hold then go to up".

      How can I do this?
        • 1. Re: MC with 4 button states
          kglad Adobe Community Professional & MVP
          if you're trying to create a toggle effect use:

          • 2. Re: MC with 4 button states
            jl2000 Level 1
            kglad - That's cool! It works great. I put it right inside box_mc and left out all the "box_mc"s in the code.

            Thanks.

            How does "this.toggle=!this.toggle" ? "toggle equals NOT toggle"??? Is "toggle" a reserved word or something?

            JL
            • 3. Re: MC with 4 button states
              kglad Adobe Community Professional & MVP
              you're welcome.

              no, toggle is a simple author-defined boolean variable. like all booleans:

              boolVar=!boolVar;

              simply changes the value from true to false or from false to true. ie, it alternates between those booleans and can be used for toggling.
              • 4. Re: MC with 4 button states
                jl2000 Level 1
                kglad -
                The toggle Saga continues.

                I've used the toggle code you provided successfully in the mc described earlier.... "It has 4 states, up, over, down and hold...10 frames apart on the timeline." I put the toggle code on the first frame of that mc and named it box_mc. If I drag an instance on the stage it works great.

                To make use of this multiple times I nested box_mc into other movie clips and added a layer for the specific "button label" text (tools, links, topics, etc). So now I have box_mc inside the mc named btn_tools.

                I'm applying an onRelease to btn_tools to trigger some other stuff moving on the stage (toolsView). But
                I can either get the states of box_mc OR the action that's supposed to happen onRelease. Naturally I want both. See the first 2 snippets.

                To continue with this mess I cut out the nesting part and just duplicated box_mc, renamed it mc_tools, added a layer to it , put the "button label" text on that layer and tried to address mc_tools on the stage. Remember that the toggle code is on frame 1 of of this now. When I use the third snippet below - I get the pretty "over" , "hold" states but not toolsView on the stage.

                How can I get the results I want?

                Thanks for your help.
                jl



                • 5. Re: MC with 4 button states
                  kglad Adobe Community Professional & MVP
                  if you apply mouse handlers to a parent and to a child movieclip the child movieclip will not respond to mouse events because the parent movieclip intercepts those events.

                  to remedy, you must either code all mouse handlers on the child generation all use a hitTest() (instead of mouse handlers) for the parent or child.