PDA

View Full Version : check condition problem



hsadan
April 2nd, 2004, 05:16 AM
i'm trying to create a game that has a similar concept as Dance Dance Revolution - if shown is a down arrow then press down, if up arrow is shown then press up ...

i'm having problems with the "if shown is a ... arrow" part - i managed to get pressed key check working, so if you press the correct key you'll progress but if you press the wrong one the appropriate action will execute.

in frame 1 i have the movieclip that contains the arrow display with the following code:

onClipEvent(keyDown){
if (_global.x = "up") {
if (Key.isDown(Key.UP)){
gotoAndStop("down");
_global.x = "down";
_root.wrong.text="ok";
}else if (Key.isDown(Key.DOWN)){
_root.wrong.text="wrong!";
}else if (Key.isDown(Key.LEFT)){
_root.wrong.text="wrong!";
}else if (Key.isDown(Key.RIGHT)){
_root.wrong.text="wrong!";
}
} else {
_root.wrong.text="wrong!";
}
}

then for the actions for frame 1 itself:
_root.instructions.gotoAndStop("up");
_global.x =" up";
stop();
instructions is the name of my mc

looks ok to me, but when i tested by changing the if condition for the mc action to if (_global.x = "down") the thing still executed as if _global.x = "up" .

anyone can help?

virusescu
April 2nd, 2004, 06:35 AM
as said before... :)

if (_global.x == "up")
= is use to asignate the value to the right to the variable in the left
and == is used to verify

hsadan
April 2nd, 2004, 07:43 AM
ohh thanks a lot!