kaspernov
kaspernov

Reputation: 141

How to make button clickable only once in actionscript?

I have two scenes in Flash.

In the first I have a button and if somebody click on that button it goes to the second scene.

In the second scene I remove the button with an image so it is not clickable.

How to leave this button, but make it not clickable at all?

and the second case is what if I am using just one scene in flash and want the button be clickable only once? How the actionscript will look like?

Thanks in advance.

Upvotes: 2

Views: 3025

Answers (3)

Benny
Benny

Reputation: 2228

var ft:Boolean = true;
myBtn.addEventListener(MouseEvent.CLICK, action);
function action (e:MouseEvent):void 
{
    if(ft)
    {
        myBtn.enabled = false;
        //myBtn.visible = false;
        trace("licked");
        ft = false;
    }
}

If as3, try this....

Upvotes: 2

Matt Stein
Matt Stein

Reputation: 3053

Buttons and MovieClips both have two properties you can use, enabled and visible. If you want the button to be visible but not clickable, do this:

myButton.enabled = false;

If you want to hide it altogether and also ensure that it can't be clicked:

myButton.visible = false;

If this is ActionScript 2.0, just add underscores to the properties:

myButton._enabled = false;
myButton._visible = false;

Upvotes: 1

Malketh
Malketh

Reputation: 101

button.onPress = function()
{ 
  button.enabled = false; 
} 

Upvotes: 0

Related Questions