-
how to make a button can be used once only
hello,
i would like to know how to make a button to be used once only. for example, i made a button and it'll add score when i press it. i only want it to score once, but since i used a on(release), so it'll continue to add score when i keep clicking it. is there a way to make it happen once only?
here is the actionscrpit that i'm using.
on (release) {
_root.score += 100;
}
please help me!
-
Flashmatics
on the first frame of the timeline put this code in the actions layer.
var scorepressed = false;
then in the button:
on (release) {
if(_root.scorepressed == false){
_root.score += 100;
}
scorepressed = true;
}
-
Give to the button a name, say myButton.
Then disable it as soon it is pressed:
on (release)
{
myButton.enabled = false;
_root.score += 100;
}
You will just get it pressed once...
-
it works!!! thank you so much!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|