phore_eyes
427 posts
|
how would i make it so that when you click on a button it then goes away and you cannot click it any more
|
|
|
Janck
253 posts
|
Give your button an instance name, such as “genericbtn”.
In the button’s actions:
on (press) {
...
...
genericbtn._visible = false
...
...
}
|
|
|
phore_eyes
427 posts
|
does this make it so you can’t click it or you can’t see it?
|
|
|
Janck
253 posts
|
|
|
|
phore_eyes
427 posts
|
|
|
|
yrudoy
341 posts
|
I just move the button off of the screen. (:
|
|
|
Nabb
1002 posts
|
You can tab to an offscreen button ;)
|
|
|
yrudoy
341 posts
|
|
|
|
phore_eyes
427 posts
|
sorry that code didn’t work for some reson any other help???
|
|
|
phore_eyes
427 posts
|
ok i got it so that the button is gone but when you go to the frame again it’s there again is there any way to make it stay gone
|
|
|
ch00se
98 posts
|
I’m not sure how you’re coding. If you’re using classes to store Object variables you can create a boolean variable that tracks when the button should be in a visible state, then just attach an if statement.
|
|
|
Nyde
25 posts
|
Going off on ch00se’s idea: a way you can hide your button and keep it hidden when it enters the frame again is doing the following:
Say you have a button with an instance name myButton. You can place the following block of AS in the same frame as your button.
var buttonVisibility:Boolean; //declare a boolean variable
if(buttonVisibility == undefined) {
myButton._visible = true; //button hasn't been clicked yet
} else {
myButton._visible = buttonVisibility; //if it's defined then hide the button
}
// this function handles the button being clicked event
myButton.onRelease = function(): Void {
buttonVisibility = false; //set the boolean to false
myButton._visible = buttonVisibility; //immediately set visibility of the button to false
}
Just read the comments to see how it works. I tested this in Flash 8 and it works on my end. Let me know if this solves your issue.
|
|
|
phore_eyes
427 posts
|
sorry i havent replied yet i was out camping any ways when i use that code this comes up
Scene=Scene 1, Layer=back, Frame=167: Line 10: ‘{’ expected
myButton.onRelease = function(): Void {
Scene=Scene 1, Layer=back, Frame=167: Line 13: Unexpected ‘}’ encountered
}
any help here
|
|
|
Janck
253 posts
|
Nyde, are you sure that
: Void
is completely necessary?
|
|
|
arcaneCoder
2354 posts
|
@Janck: “:Void” just indicates that the function doesnt return anything. Its actually good practice to put that.
|
|
|
Janck
253 posts
|
It makes sense, but it seems that phore_eyes’ flash doesn’t like it, though.
|
|
|
phore_eyes
427 posts
|
so i should try taking : void out???
|
|
|
Nyde
25 posts
|
@Janck: it will work without “Void” — but just because it works, doesn’t mean it’s the best way to do it. I put that there because, like arcaneCoder said, the function isn’t returning anything.
@phore_eyes: What version of Flash are you using? I guess try “function() {}” instead of “function(): Void {}”… or try and take out the space in between the semi-colon and Void.
|
|
|
Nyde
25 posts
|
Just an aside: can anyone think of a better way to do this? I really hate checking to see if a variable is “undefined” in that “if” statement.
|
|
|
phore_eyes
427 posts
|
|
|
|
JudeMaverick
8844 posts
|
Flash MX is outdated. Our flash are mainly Flash 8 and Flash CS3.
|
|
|
Janck
253 posts
|
Be careful of updating too much. You’ll lose Wii compatibility.
|
|
|
JudeMaverick
8844 posts
|
It’s Adobe’s fault that “external things need to be added so they can use Flash Player 8 and above”. It’s also Adobe’s fault that 2DArray’s newest game, Chatmaster, took a long time to publish >:(
|