Need help for create flash game

i am actually doing a Game and Watch style flash game for my assignment…
but i am stuck now…
my game have a shoot action when pressing the space bar. so when enemy comes out, go to that direction, space bar to kill it. so just wondering
can i just put the code under Key Space to detect and kill enemy?
something like this

Key.addListener(keyboard);

if(Key.getCode()==Key.SPACE){

            if(char_mc._currentframe==1){
                    
                    char_mc.frame_mc.gotoAndStop('spray');
                    if(enemy1._currentframe==1){
                            enemy1.inside1_mc.gotoAndPlay('die')
                            trace('die1');
                            
                    }
                    
                    
            }

this is not working… i not sure is this something wrong or need to use other way to do it?

someone help me pls… thanks