Code:
onClipEvent (enterFrame) {
if (_root.background_mc._x <= -3620) {
_root.background_mc._x = -3620;
} else if (_root.background_mc._x >= 22) {
_root.background_mc._x = 22;
}
if (Key.isDown(Key.LEFT) || _root.toLeft) {
this.gotoAndStop("walk_left");
if (_x <= leftsensor) {
_root.background_mc._x += bg3;
} else {
_x -= playerspd;
}
}
if (Key.isDown(Key.RIGHT) || _root.toRight) {
this.gotoAndStop("walk_right");
if (_x >= rightsensor) {
_root.background_mc._x -= bg3;
} else {
_x += playerspd;
}
}
if (!Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT) || (!_root.toLeft && !_root.toRight)) {
this.gotoAndStop("rest");
}
}
Left button
Code:
on (press) {
_root.toLeft = true;
trace(_root.toLeft)
}
on (release, releaseOutside) {
_root.toLeft = false;
}
Right button
Code:
on (press) {
_root.toRight = true;
}
on (release, releaseOutside) {
_root.toRight = false;
}