At 11/7/09 09:50 AM, blubfaceproduction wrote:
If you're in AS 2.0, here's how you make it happen. Put this code on the symbol you want to move:
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= speed;
}
if (Key.isDown(Key.UP)) {
_y -= speed;
}
if (Key.isDown(Key.DOWN)) {
_y += speed;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
}
speed = 10;
}
I strongly suggest you avoid using this method. Putting code on moviclip might seem easier at first, but as you progress it will only drag you down and mess up your projects. All you need to do is to give an instance name to your clip and put your code inside functions on the main timeline like this
var speed:Number=10;
this.onEnterFrame=function(){
yourFunction();
}
function yourFunction(){
//your code
if (Key.isDown(Key.LEFT)) { this.yourMC._x -= speed;}
if (Key.isDown(Key.UP)) { this.yourMC._y -= speed;}
if (Key.isDown(Key.DOWN)) { this.yourMC._y += speed;}
if (Key.isDown(Key.RIGHT)) {this.yourMC._x += speed;}
}