Social Question

Kameron's avatar

What AS2 Code do I use for Show/Hide MovieClips?

Asked by Kameron (14points) January 5th, 2010

I am making a RPG/MMO Both features available for the player, however I can not figure this out. How could I Show a Movie clip on a Button Click, then Hide on another button click.

What I want to do, is when clicking a Button your inventory or another menu Item pops up, then you can close as well.

Observing members: 0 Composing members: 0

3 Answers

markyy's avatar

You can use attributes like movieclip._visible = false, or movieclip._x = -99999 to move it to a position of the screen where it can’t be seen. This is all pretty basic stuff really, here is a good collection of tutorials.

ParaParaYukiko's avatar

I would probably do something with changing the alpha of the movie clip. That seems the simplest way to me. You can do this with a script like this:

on (release) {
YourMovieClip._alpha = 100;
}
to show the MC, or

on (release) {
Your MovieClip._alpha = 0;
}

to hide it.

scruffpuff's avatar

@ParaParaYukiko Setting alpha like this is one approach however keep in mind that if something has an alpha of 0 it can still be a target for events which might be undesirable.

For example, saying:

myClip.onRelease = function()
{
myClip.alpha = 0;
}

will make the clip transparent, however if you mouse over where that clip was on the stage you’ll still get a hand cursor because the object still has a _visible property of true.

Setting myClip._visible = false is probably the best way to do it because not only will the clip be invisible but it also won’t be clickable anymore till you set it’s _visible property back to true.

Answer this question

Login

or

Join

to answer.
Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther