9 Replies Latest reply on Feb 16, 2007 8:49 AM by ggshow

    Making a component invisible...

    Jim4276
      Hi,

      I'm trying to make a component in my movie invisible using the instance._visible = false ActionScript command. It's a button that was converted to a symbol from a series of filled rectangles and ovals. It will not go invisible although I can use the same script on a simple, independent text-box and it works fine. Am I missing something?

      Thanks in advance - Jim.
        • 1. Re: Making a component invisible...
          cinemaguy Level 1
          You can try putting this on your first frame....

          mc.onEnterFrame = function() {
          this._visible = false;
          };
          • 2. Re: Making a component invisible...
            ggshow Level 2
            if you are using a flash UI component,

            instanceName.visible = false;

            * no underscore _
            • 3. Re: Making a component invisible...
              cinemaguy Level 1
              Will that work for a component that has been converted to a movieclip though?
              • 4. Re: Making a component invisible...
                ggshow Level 2
                yes

                movieclipInstanceName.componentInstanceName.visible = false;

                or

                movieclipInstanceName._visible = false;
                • 5. Re: Making a component invisible...
                  nc2dc
                  Hi -
                  I tried both ways (._visible and just .visible) but the button never disappears. What I have is a button within a movie clip. Via action script, I am able to tween the movieclip to a new location on the stage when the button is clicked. I'm also using onMotionFinished to detect when the animation has stopped and then to trigger the disappearance of the button (so that the user can not select it). Can anyone provide insight into why setting _visible or .visible to false does not work in this scenario?

                  Here's a snipper of my code:

                  thanks -bui
                  **************************************************************
                  • 6. Re: Making a component invisible...
                    ggshow Level 2
                    if you means an instance of button symbol, this script works:

                    triggerBox_red_btn.onPress = function(){
                    this._visible = false;
                    }

                    if you means an instance of Button UI component, it has no _visible nor visible properties. You may want to use another method called "destroy object"

                    var listenerObject:Object = new Object();
                    listenerObject.click = function(eventObj:Object) {
                    destroyObject("triggerBox_red_btn");
                    };
                    triggerBox_red_btn.addEventListener("click", listenerObject);

                    • 7. Making a component invisible...
                      nc2dc Level 1
                      Thanks for responding. It's working. But I still have some minor questions.

                      1) When I put the code within the onMotionFinished function, it doesn't work. But when I place it at the very beginning (before the tweening), it works. Why is this?

                      2) Also, what is the difference between using:
                      this._visible = false; versus this.red_mc.triggerBox_red_btn._visible = false; or just red_mc.triggerBox_red_btn._visible = false;? The latter 2 do not work. Why is this?

                      thanks you very much for your help.

                      Here's the modified snippet with the new code:
                      ********************************************************
                      • 8. Making a component invisible...
                        ggshow Level 2
                        when you write "this" inside the onPress function

                        this.red_mc.triggerBox_red_btn.onPress = function () {
                        // if you write "this" here, it is already means this.red_mc.triggerBox_red_btn, as highlighed above. So when you write "this.red_mc.triggerBox_red_btn" here, it means this.red_mc.triggerBox_red_btn.red_mc.triggerBox_red_btn
                        }
                        • 9. Re: Making a component invisible...
                          ggshow Level 2
                          the same reason as previous message,

                          tween_handler.onMotionFinished = function() {
                          //when you place your action here, "this" refering to "tween_handler"
                          }