PDA

View Full Version : whats wrong with this "if else" statement


pisosse
10-11-2005, 06:00 PM
I think it really realy simple but somthing is very very wrong

LOOK HERE (http://www.mentalindustries.com/detection)


as u see the first two buttons and mc's are working proberly but the last one is acting all funny on me

can any one see a problem with this code

blue_btn.onRelease = function(){

if (red_mc._y = 100) {
red_mc._y = 200;
}
else if (green_mc._y = 100) {
green_mc._y = 200;
}
blue_mc._y = 100;
};

red_btn.onRelease = function(){

if (blue_mc._y = 100) {
blue_mc._y = 200;
}
else if (green_mc._y = 100) {
green_mc._y = 200;
}
red_mc._y = 100;
};

green_btn.onRelease = function(){

if (red_mc._y = 100) {
red_mc._y = 200;
}
else if (blue_mc._y = 100) {
blue_mc._y = 200;
}
green_mc._y = 100;
};

Cota
10-11-2005, 06:19 PM
You're using the = instand of ==

if (red_mc._y == 100) {
red_mc._y = 200;
}
else if (green_mc._y == 100) {
green_mc._y = 200;
}
blue_mc._y = 100;
};

red_btn.onRelease = function(){

if (blue_mc._y == 100) {
blue_mc._y = 200;
}
else if (green_mc._y == 100) {
green_mc._y = 200;
}
red_mc._y = 100;
};

green_btn.onRelease = function(){

if (red_mc._y == 100) {
red_mc._y = 200;
}
else if (blue_mc._y == 100) {
blue_mc._y = 200;
}
green_mc._y = 100;
};

box86rowh
10-11-2005, 07:50 PM
one thing to definately remember..
the == compares while the = assigns

Jason

pisosse
10-12-2005, 03:22 PM
doooh.... damn I actually did it first and then rewrote it before i checked it...

THANKS FELLARS *SMACK*

jsebrech
10-12-2005, 03:42 PM
I don't know any developer who doesn't mistype this every once in a while. This is one aspect I like about delphi, "=" compares and ":=" assigns. I don't know why, but that syntax makes me write these kinds of mistakes less.