Keystroke Control

I needed some actionscript that would toggle a movieclip on and off with the same keystroke. I got working but after hitting the key multiple times back and forth the movie starts to slow and I get “A script in this movie is causing Flash Player to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort the script?” This is no good! here’s the script I used on a frame of the main timeline that flips between 2 labeled frames to get the toggle effect:

keyListener = new Object();
keyListener.onKeyDown = function () {
if (Key.getAscii() == 49) {

Thanks for any help!