Loop codnition question? (Beginner D:)

Hey all, I’ve begun scripting in AS2 today, which makes me a beginner in AS2. I do however have quite a bit of experience programming, so I know most of what I need to know.

My question is about the loop functions in AS2. I don’t believe the for statement fits exactly what I need done, so that’s where I need a bit of help.

onClipEvent (load) {
    speed = 0;

onClipEvent(enterFrame) {
    this._x += speed;
    if (Key.isDown(Key.RIGHT)) {
        speed += 1;
    } else {
    speed -= 1;

This is to produce a smooth movement when the right key is pressed. The line of code where I have set the else statement to “speed -= 1” is where I am having trouble. I only want that line to run when the speed variable is greater than 1, and to repeat until “speed <= 0”

EDIT: I forgot to mention that I also want the script to repeat when he right key is not pressed, unless that is irrelevant. I’m tinkering around with the operations I know of (While (), for (), and do-while) to no avail. I’ll delete the post if I find a solution, which is unlikely haha

This will help me very much, as I am also creating limited physics in this project. Thanks much :smiley: