PDA

View Full Version : Visibility problem.


Miakosummin
07-31-2006, 10:00 AM
On frame 7 of the main movie I have a button that I want to start off invisible. On the same frame, theres another button that you click to make the first button visible. Clicking the now-visible first button hides itself.

I have no idea how to do this unfortunatly. It seems really easy but it just doesn't want to work.

My idea was that when you hit the play button on the preloader, it will set that button to visible, but when I click that button it does nothing.

Also, by the way, every frame has a stop() attached to it, with buttons that have gotoAndStop(_) on them.

On frame 1: Button with instance name "play":
on (release) {
_level0.unfold._visible=0;
gotoAndStop(2)
}
and on frame 7 there is a Button with instance name "unfold"

I have tried lots of things, and poured over tons of tutorials, but I just can't seem to make this work... Another idea I had but haven't tried was to set the instance of unfold to be inactive and have alpha 0%, and clicking the revealing button makes the second button active and alpha 100%. However, that requires more typing which I don't think I need to do...

Thanks for the help.

BernzSed
08-01-2006, 01:05 AM
First of all, _visible is a boolean property, not a number. That means, to make something invisible and inactive, you would use _visible = false;

Also, I wouldn't use "play" as an instance name, since that word is used for something else.

Also, if you are on frame 1, you can't access an object on on frame 7, because it doesn't exist at the moment.
How best to get around this depends what you've done and what you're trying to achieve, but here's one possible way:


Have the code on your play button be this:on (release) {
_root.unfoldIsVisible = false;
_root.gotoAndStop(2);
}and on frame 7, use this code:if(!_root.unfoldIsVisible){
unfold._visible = false;
}If you wanted to make that button visible, you would set it's _visible property to true, and change the _root.unfoldIsVisible variable to false.

If that doesn't help, it might help to attach your FLA.

Miakosummin
08-01-2006, 01:34 AM
Oh man, thank you so much. I feel so stupid to not have figured that out on my own.
Although just a question, what exactly does the "!" do in the "if(!_root.unfoldIsVisible)"?

BernzSed
08-01-2006, 01:39 AM
! means "not". Basically, if the statement after it evaluates to "true", the ! changes it to false, and vice versa.


Hey, here's a useful link:
http://livedocs.macromedia.com
Then, click on your version of Flash in your language, and click on "ActionScript Language Reference".

Glad I could help!

Miakosummin
08-01-2006, 01:56 AM
Ahh, alright.... Hm, just so I can be sure,
if (xxxxx){
do whatever}
is the same thing as
if (xxxxx=true){
do whatever}
right? Although, to be honest, I'm not sure if the second code is correct in actionscript, but if(xxxxx) means "if xxxxx equals true", right?

BernzSed
08-01-2006, 02:22 AM
Ahh, alright.... Hm, just so I can be sure,
if (xxxxx){
do whatever} is the same thing as
if (xxxxx=true){
do whatever} right? Although, to be honest, I'm not sure if the second code is correct in actionscript, but if(xxxxx) means "if xxxxx equals true", right?

Almost!

You use "=" when you want to set the value of a variable. Within an if() statement, you'll want to use "==".