PDA

View Full Version : If Condition asking for two variables to be set



dualaud
May 17th, 2005, 07:07 PM
for i know that i often fail :blush:when it comes to syntax, i thought i might ask how the syntax would be if i'd want to ask if two variables are set.
say i'd want to let things happen if the variables _root.move==1 and at the same time _root.window==0. :h:

in this piece of code:

onClipEvent (enterFrame) {
if (_root.move == 1) {
if (_root.mainVarX == 0) {

homeX = (-_root._xmouse*1)+328;
homeY = (-_root._ymouse*1)+400;

} else {

homeX = (-_root.mainVarX);
homeY = (-_root.mainVarY);

}

thisX = _x;
thisY = _y;
diffX = homeX-thisX;
diffY = homeY-thisY;

if (_root.mainVarX == 0) {
moveX = diffX/10;
moveY = diffY/10;
} else {
moveX = diffX/10;
moveY = diffY/10;
}

_y = thisY+moveY;
_x = thisX+moveX;

}
}

my problem is, that i let something scroll in front of a button on mouse release, and flash now thinks that i left the button and thinks it should fire up stuff that should happen on rollout, which shouldn't when i mouse release on the button.

thanks for your help. i figured, i better ask before i go mad for two days ;P

dualaud
May 17th, 2005, 07:32 PM
k, i have it:
:sure:
for the record:
this
if ((a == 1) && (b == 1)) {
}

is the syntax to use.
in reference to my example:

if ((_root.move == 1) && (_root.window ==0)) {
if (_root.mainVarX == 0) {

homeX = (-_root._xmouse*1)+328;
homeY = (-_root._ymouse*1)+400;

} else {

homeX = (-_root.mainVarX);
homeY = (-_root.mainVarY);

}

thanks,
dual

999
May 17th, 2005, 07:39 PM
I was just about to say that! :lol: Only I would have said use "and" instead of "&&".

dualaud
May 17th, 2005, 09:27 PM
does it matter which one i choose?:|

999
May 17th, 2005, 09:58 PM
I have no idea? :-/ I picked "and" up somewhere along the line so thats what Ive been using for comparisons. It would seem they both do the same thing in this situation but theres probably a specific use for one or the other.

I just dont know what that is?

fasterthanlight™
May 18th, 2005, 12:08 AM
did you also know about enclosing your script that you post with [ as][/ as] tags? (no spaces though, when you use them) This colour codes everything, and even indents it so we can read it better! :)

999
May 18th, 2005, 12:23 AM
This colour codes everything, and even indents it so we can read it better! :)One of my favorite Kirupa forums features :love: .