Problem with Button function

Hi Friends,

I have different buttons on my stage to go to different frame…

To avoid multiple function, I write single function like this:

targetFrame (btn1, "frame_q1");
targetFrame (btn2, "frame_q2");
targetFrame (btn2, "frame_q3");

function targetFrame (btn:Button, questionFrame:String):void {

    btn.addEventListener (MouseEvent.CLICK, gotoQuestion);

    function gotoQuestion (evt:MouseEvent) {
        gotoAndPlay (questionFrame);
    }
}

But its not working …
// this is showing erroe 1046
Please help me…