|
-
If Statement code generating errors - help!
I'm having problems getting my if statement to work. I have 4 flowers on screen as buttons, and i want to be able to click on them to 'pick' them (make them disappear). Once all 4 flowers have disappeared/been picked i want to go to a new frame label.
The code i put in to make the flowers invisible once clicked worked. But when i tried to add an if statement to check whether all flowers had disappeared to move on to the next frame label, i kept getting error messages.
This is my code:
var flower1:Boolean = true;
var flower2:Boolean = true;
var flower3:Boolean = true;
var flower4:Boolean = true;
flower1_btn.onRelease = function() {
flower1 = false;
flower1_btn._visible = false;
if (flower1 = false && flower2 = false && flower3 = false && flower4 = false){
gotoAndPlay("badgerSmile")
}
};
flower2_btn.onRelease = function() {
flower2 = false;
flower2_btn._visible = false;
if (flower1 = false && flower2 = false && flower3 = false && flower4 = false){
gotoAndPlay("badgerSmile")
}
};
flower3_btn.onRelease = function() {
flower3 = false;
flower3_btn._visible = false;
if (flower1 = false && flower2 = false && flower3 = false && flower4 = false){
gotoAndPlay("badgerSmile")
}
};
flower4_btn.onRelease = function() {
flower4 = false;
flower4_btn._visible = false;
if (flower1 = false && flower2 = false && flower3 = false && flower4 = false){
gotoAndPlay("badgerSmile")
}
};
stop();
The error message I am getting is as follows:
Left side of assignment operator must be variable or property.
if (flower1 = false && flower2 = false && flower3 = false && flower4 = false){
It seems that it does not like my if statement condition, even though i thought i had defined the flowers as variables.
If anyone can help me out with this problem, i would be very grateful. I am using Flash8 Pro
Thanks
-
if (flower1 = false && flower2 = false && flower3 = false && flower4 = false){
if (flower1 == false && flower2 == false && flower3 == false && flower4 == false){
== checks to see if it equals
= sets the value of the variable to it
-
FK'n_dog
you need == to make comparisons -
if (flower1 == false && flower2 ==......)
as you are checking for Boolean false you can use -
if (!flower1 && !flower2 &&......)
-
Thanks
Thanks so much - that works a treat!
I'll remember that in future, cheers.
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
|