Jumping between two frames at the press of a button

This isn’t working right. From what I understand, it should, but it doesn’t. What am I doing wrong?


on(release){
    var targetFrame = this._currentframe;
    if(targetFrame == 10){
        gotoAndStop(1);
    }else if (targetFrame == 1){
        gotoAndStop(10);
    }
    trace("Frame number=" + targetFrame)
}

The trace returns “1” every time I press the button.