Class only "active" when movieclip on frame

Hello,
I am making a game and the setup for the “hero” MovieClip is as following:
The first frame contains a movieclip that has the feet and the walk animation has a stop on the first frame and a movieclip of a class. This class checks if an arrowkey is pressed and then plays the walk animation.

Now when you jump, the original hero MovieClip skips to a frame that shows the feet in a jumping position. Of course, now the whole feet-walk movieclip isn’t there anymore.

But now the walkanimation-class fires a million errors, because it can’t play, obviously.

What I want to do is, for the walkanimation class to only “react” when the movieclip that is connected to the class is existing right at the moment. Apparently right now the class reacts all the time.

Is that possible?