So I have a movie clip called signInBtn and one called signOutBtn initially,
signOutBtn.visible = false;
but when a user signs in
signInBtn.visible = false;
signOutBtn.visible = true;
But after I do that, I can't click the signOut movieclip. I thought it might be because the signOutBtn w开发者_Python百科as under the invisible signInBtn but that is not the case.
package
{
import fl.controls.Button;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class Test extends Sprite
{
private static const SIGN_IN:String = "Sign In";
private static const SIGN_OUT:String = "Sign Out";
private var button:Button;
public function Test()
{
button = new Button();
button.addEventListener(MouseEvent.CLICK, buttonClickEventListener);
button.label = SIGN_IN;
addChild(button);
}
private function buttonClickEventListener(evt:MouseEvent):void
{
switch (button.label)
{
case SIGN_IN: button.label = SIGN_OUT;
trace("Signed in");
break;
case SIGN_OUT: button.label = SIGN_IN;
trace("Signed out");
}
}
}
}
Edit
signout works when it is in a different position to sign in but when it is in
the same position as signin it cant be clicked. when the sign out button is half
over the same position as the signin button, half the signout button works and
half doesnt
If you have a MovieClip or a Sprite on top of another, the mouse event will be screened, there are ways around that though. In any case , in your example, simply disable a button when you don't need it
signInBtn.visible = false;
signInBtn.mouseEnabled = false;
signOutBtn.visible = true;
End of Edit
There's no apparent reason why signOutBtn shouldn't be clickable after its visibility has been toggled. The error is somewhere else.
Make sure both buttons are clickable before changing their visibility.
Have you added event listeners to both buttons, are you removing event listeners after the event has been fired?
精彩评论