4 Replies Latest reply on Dec 19, 2008 8:33 AM by W_Bell

    AS2 Nested Button - Toggle Visibility

    W_Bell Level 1
      I have 2 buttons (mc) called zoomBig_mc & zoomSmall_mc
      zoomBig_mc is on top of zoomSmall_mc

      When the user clicks zoomBig_mc it calls a function then hides itself so zoomSmall is then visible.
      When the user clicks on zoomSmall it calls a function and then sets the visibility of zoomBig to true.

      I can get these to work if in the main time line but not when they are nested 2 deep.
      ie.

      zoomBig & zoomSmall are inside RightPlayBar which is inside MainPlayBar
      so it is nested 2 deep.

      Any body have any solutions other than a whole new re-design?
        • 1. Re: AS2 Nested Button - Toggle Visibility
          clbeech Level 3
          what exactly is the problem? will the visibilities not toggle? or do they no longer scale the mc correctly?

          in either case it is most likely a 'path' issue, wherein your must target either the button(s), the mc to be scaled, or the method using the correct path.

          if the trouble is that you cannot fire the method (function) because it still resides in code elsewhere in the document (like on the main timeline) you need to target that method with the correct path - and although i'm not a fan of using this - you can call to the method using _root, as in:

          _root.myMethod();

          it appears that you could also target the same method by using:

          _parent._parent.myMethod();

          the same will be true of any other object within the file (ie. your mc to be scaled) one can target any object, anywhere (with certain limitations, for instance, whether or not the object is currently instantiated) by calling the correct 'path' to the object.

          hope this is helpful :)
          • 2. AS2 Nested Button - Toggle Visibility
            W_Bell Level 1
            I am wanting to hide a nested button(mc) by clicking on it.
            The button I want to hide is nested 2 deep.
            The button calls a visibility funtion in the main frame.

            FYI
            The button calls a function that scales the video with ChangeProp....
            The function works fine, I just can't seem to target the nested button to hide.
            • 3. Re: AS2 Nested Button - Toggle Visibility
              Ned Murphy Adobe Community Professional & MVP
              One way to have the button's visibility controlled is via the buttons themselves (or the other). Is that what you are doing, or are you trying to get the main timeline function that the button calls to set/reset the vutton visibility?

              cl's offering will get the function in the main timeline working from where you say the buttons are.

              this.zoomBig_mc._visible = true; can be set by zoomSmall_mc

              this.zoomBig_mc._visible = false; can be set by zoomBig_mc itself

              To target from the function two parents away you would use...

              MainPlayBar.RightPlayBar.zoomBig_mc._visible = ....

              Whatever you do, I doubt there is any reason to start from scratch.

              • 4. AS2 Nested Button - Toggle Visibility
                W_Bell Level 1
                Well, this issue was a path problem and is now solved.
                I have also sstreamlined to code as follows;

                //Toggle Loader Zoom button
                myButton_Zoom = function () {
                controls_LH.bt_zoombig_mc._visible = !controls_LH.bt_zoombig_mc._visible;
                };



                Thank you clbeech and Ned, for pointing me in the right direction...

                W Bell