onEnterFrame=function() problem

I have a serious problem with this code:

 
onEnterFrame=function(){
 _root.talktimer--
if(_root.talktimer<=0 && Key.isDown(88)){
gotoAndStop(46)}}

for some reason if im on a different frame other than 45 if I press x it goes back to 46. Anyhelp with this? Thanks