AS 3:找不到现有功能?

时间:2013-01-29 20:02:30

标签: actionscript-3 flash

我的程序编译有一个奇怪的错误......

对于我的程序场景,它只是一个名为“perso”的MovieClip,用键盘的箭头移动。

Flash告诉我,无法找到“clavierUp”和“animation”属性访问。

我真的不明白......

var perso:Perso = new Perso();

stage.addEventListener(KeyboardEvent.KEY_DOWN, clavierDown);
stage.addEventListener(KeyboardEvent.KEY_UP, clavierUp);
stage.addEventListener(Event.ENTER_FRAME, animation);

function clavierDown(e)
{
    switch(e.keyCode)
    {   
        case Keyboard.LEFT:
            perso.speedX = -speedHero;
            break;
        case Keyboard.RIGHT:
            perso.speedX = speedHero;
            break;
        case Keyboard.UP:
            perso.speedY = -speedHero;
            break;
        case Keyboard.DOWN:
            perso.speedY = speedHero;
            break;
    }

function clavierUp(e)
{
    switch(e.keyCode)
    {
        case Keyboard.LEFT:
            perso.speedX = 0;
            perso.scaleX = -1;
            break;  

        case Keyboard.RIGHT:
            perso.speedX = 0;
            perso.scaleX = 1;
            break;

        case Keyboard.UP:
            perso.speedY = 0;
            break;

            case Keyboard.DOWN:
            perso.speedY = 0;
            break;
    }
}

function animation(e)
{
    animeHero();
}

谢谢!

1 个答案:

答案 0 :(得分:0)

对不起,我在“clavierDown”函数结束时错过了一个右边的行为......