-
IF / Else help for matching game
Hi guys,
I'm a real Flash noob. Trying to make a game where you click a box and it disappears and reveals content below it for a matching game where you find like flags (like US flag, Italian, etc) and I am trying to work with IF/Else in Flash CS3, but I haven't done code since Flash MX and I'm lost in the newer UI.
Anyway, I'm working in Actionscript 2.0 because 3.0 still scares me and here is my code:
on (press) {
if (thecount = 0){
_root.A1._visible=false;
set (_root.thecount, 1);
} else if (thecount = 1){
_root.A1._visible=false;
set (_root.thecount, 2);
} else {
stop();
}
}
I have a series of "rectangle covers" on top of flag graphics. What I want to happen with the code above is to have it so when the variable thecount is 0 or 1, a mouse click will turn a rectangle cover invisible to show a flag, and if thecount is anything else, I don't want anything to happen when the user clicks on the rectangle cover.
I found out that I needed (or maybe I don't) the _root for the visible code, but I can't figure out how to get the above IF/Else right. The above code right now makes the rectangle cover invisible (A1) invisible no matter what thecount equals.
Thanks for any help!!! Also i'm sorry i don't know the UBB to get the code above looking nicer :/
Last edited by G.v.P; 03-22-2009 at 09:01 AM.
-
FK'n_dog
usual noob mistake
== needed for making a comparison -
if (thecount == 0){
.....
} else if (thecount == 1){
-
Originally Posted by a_modified_dog
usual noob mistake
== needed for making a comparison -
if (thecount == 0){
.....
} else if (thecount == 1){
Well, I actually tried that :/ but when I change = to == nothing happens at all when i click on the rectangle cover (A1). Maybe I need to specify the target differently...A1 is a movie clip with the actionscript on it so when you click it, it should disappear if the "thecount" variable is correct. Hmmm.
-
Code:
on (press) {
if (_root.thecount == 0){
_root.A1._visible=false;
_root.thecount = 1;
} else if (_root.thecount == 1){
_root.A1._visible=false;
_root.thecount = 2;
} else {
stop();
}
}
-
:/ still not working I wonder what I am doing wrong...
ahhhh ha! i got it! thanks so much guys i had to make sure thecount was defined in code, set = 0 by default (I thought I could just enter 0 in the field to define it as default)
Last edited by G.v.P; 03-29-2009 at 01:55 PM.
Tags for this Thread
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
|