Controlling 2 objects

hi, im trying to make a movie, that the user can control two objects at different time. A variable will act as a switch to determine which object should be controlled by the user. The following codes are written:

Frame 1:
_global.intObj1 = “1”;
_global.intObj2 = “0”;

Obj1:
on (press) {
intObj1 = 0;
intObj2 = 1;
}
on (keyPress “<Left>”) {
if (intObj1 == 1) {
object1._x = 412;
}
}
on (keyPress “<Right>”) {
if (intObj1 == 1) {
object1._x = 212;
}
}

Obj2:
on (press) {
intObj2 = 0;
intObj1 = 1;
}
on (keyPress “<Left>”) {
if (intObj2 == 1) {
object2._x = 412;
}
}
on (keyPress “<Right>”) {
if (intObj2 == 1) {
object2._x = 212;
}
}

only object1 can be controlled by the user, object2 is somehow disabled, even tho intObj2 = 1. If anyone knows how to fix my problem, or needs clarification, please reply right away, thank you!!