How Do You

move a movie clip with the arrow keys, but using coding in the Timeline in a frame? After this i have one more question…been trying to find this out for 2 days now :frowning:

Give your mc an instancename. In this example we’ll use ‘mover’ (without the ‘’). Now choose a method.

<hr>
easy method. This will overwrite any onClipEvent(enterFrame) code that resides on the mc itself.
<hr>

mover.keypressed = 0;
mover.onKeyDown = function(){
this.keypressed = Key.getCode();
}
mover.onKeyUp = function(){
this.keypressed = 0;
}
mover.onEnterFrame = function(){
//key-checking and moving goes here, something like if(this.keypressed == key.LEFT) {
this._x-= 5;
}
}
<hr>
harder (but more versatile) method. U can use other code on the mc, without disturbing the code.
<hr>
obj_mover={keypressed:0};
obj._mover.onKeyUp = function(){
this.keypressed = 0;
}
obj._mover.onKeyDown = function(){
this.keypressed = Key.getCode();
}
ob_mover.onEnterFrame = function(){
//key-checking and moving goes here, something like if(this.keypressed == key.LEFT) {
mover._x -= 5:
}
}
Key.addListener(obj_mover)
// to not listen for ikoming keypresses, use Key.removeListener(obj_mover)