Skip to main content
Participant
December 11, 2006
Question

Making a component invisible...

  • December 11, 2006
  • 7 replies
  • 722 views
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.
This topic has been closed for replies.

7 replies

Participating Frequently
February 16, 2007
the same reason as previous message,

tween_handler.onMotionFinished = function() {
//when you place your action here, "this" refering to "tween_handler"
}
Participating Frequently
February 16, 2007
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
}
Participating Frequently
February 15, 2007
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);

Participant
February 15, 2007
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:
********************************************************
Participating Frequently
December 12, 2006
yes

movieclipInstanceName.componentInstanceName.visible = false;

or

movieclipInstanceName._visible = false;
Participant
February 15, 2007
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
**************************************************************
Inspiring
December 12, 2006
Will that work for a component that has been converted to a movieclip though?
Participating Frequently
December 12, 2006
if you are using a flash UI component,

instanceName.visible = false;

* no underscore _
Inspiring
December 11, 2006
You can try putting this on your first frame....

mc.onEnterFrame = function() {
this._visible = false;
};