You just copied and pasted that into the actions of a fla, didn't you?

Don't do that. Classes should be defined in .as files which match the class name, and in a directory structure which matches the package name.

Since, in this case, the package name is empty, the .as file should live somewhere directly in your classpath. The same directory as the fla is a good bet.

Copy and paste that into a new file, and save that file as KeyCodes.as

Then, to use it as your document class, set the document class in the fla.