Movement Problem... (FMX)

// Movement code, v1.1
// ©2002 Tyler Albright
onClipEvent (load) {
gotoAndStop(7);
var inc = 12;
var dir = “Right”;
KeyListener = new Object();
KeyListener.onKeyUp = function() {
if (dir == “Down”) {
gotoAndStop(7);
} else if (dir == “Right”) {
gotoAndStop(5);
} else if (dir == “Up”) {
gotoAndStop(6);
} else if (dir == “Left”) {
gotoAndStop(8);
}
};
Key.addListener(KeyListener);
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
dir = “Left”;
this._x -= inc;
gotoAndStop(4);
} else if (Key.isDown(Key.RIGHT)) {
dir = “Right”;
this._x += inc;
gotoAndStop(1);
} else if (Key.isDown(Key.UP)) {
dir = “Up”;
this._y -= inc;
gotoAndStop(2);
} else if (Key.isDown(Key.DOWN)) {
dir = “Down”;
this._y += inc;
gotoAndStop(3);
}
}

That is the code i used… and it works… but the problem is… it works only on the first scene and the animation doesn’t work when moving can someone find the problem and how can you use it with other scenes…

is it yours? are you Tyler Albright?

well… first:

i woud make that change in the code:


// Movement code, v1.1
// ©2002 Tyler Albright
onClipEvent (load) {
gotoAndStop(7);
var inc = 12;
var dir = "Right";
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
dir = "Left";
this._x -= inc;
gotoAndStop(4);
} else if (Key.isDown(Key.RIGHT)) {
dir = "Right";
this._x += inc;
gotoAndStop(1);
} else if (Key.isDown(Key.UP)) {
dir = "Up";
this._y -= inc;
gotoAndStop(2);
} else if (Key.isDown(Key.DOWN)) {
dir = "Down";
this._y += inc;
gotoAndStop(3);
}
}

but i think that is not the real problem… can you post the fla here?

Whose Tyler? And who copyrights code that doesn’t work?

I think the problem is in the use of scenes. Do you repeat the code block in each scene? I think you have to do that.

?*********
this post copyright David Miller, 2003. All Rights Reserved.
*********?