gotoAndStop problem

hi to evryone,

im a newbie in flash game dev, i hope you guys can help.

i have a problem about using gotoandstop, i used in an .as file,

it has the frames of walking, idle, and attack for my side scroll game.

heres my code :

private function keyDownHandler(e:KeyboardEvent):void
{
switch (e.keyCode)

        {


            case 37:
                             hero.scaleX = -1;
                            hero.gotoAndStop('walking');
            gravityx = -2;
            
            break;
            
            case 38:
                            gravityy = -15;
            break;
            
            case 39:
                            hero.gotoAndStop('walking');
            gravityx = 2;
            break;
            
            default:
        }
    }
    
    private function keyUpHandler(e:KeyboardEvent):void
    {
        switch (e.keyCode)
        {
            case 37:
            case 39:
            gravityx = 0;
            break;
            
            default:
        }
    }

the error was :

call to a possibly undefined method gotoAndStop through a reference with static type class.

i hope you can help me.

thanks in advance .

-raphalle-