Skip to main content
SuperGibaLogan
Known Participant
Aug 15, 2023 2:39 AM UTC
Question

how do i make a movieclip move forever when the arrow keys are pressed in actionscript 2.0?

can someone give me the code that makes a movieclip move forever when the arrow keys are pressed? im working on a pac-man flash recreation, im using flash 8, also i want the movieclip to move like how pac-man moves in the original game

    This topic is closed to new replies. Start a new post to keep the conversation going.

    16 replies

    kglad
    Community Expert
    Community Expert
    Aug 16, 2023 2:56 PM UTC

    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
    if(Key.getCode()==37){
    //left
    } else if(Key.getCode()==39){
    //right
    } else if(Key.getCode()==38){
    //up
    } else if(Key.getCode()==40){
    //down
    }
    };
    Key.addListener(keyListener);

    Translate
    SuperGibaLogan
    Known Participant
    Aug 16, 2023 6:56 PM UTC

    i putted the code on the frame actions, but the movieclip isnt moving

    Translate
    SGL
    kglad
    Community Expert
    Community Expert
    Aug 17, 2023 2:55 PM UTC

    show your code.

    Translate