# Problem with Button function

**URL:** https://forum.kirupa.com/t/problem-with-button-function/294174
**Category:** flash
**Created:** [August 10, 2009, 1:57pm UTC](https://forum.kirupa.com/t/problem-with-button-function/294174 "2009-08-10T13:57:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Gyan\_Singh](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@Gyan\_Singh](https://forum.kirupa.com/u/Gyan_Singh)
#### Post date: [August 10, 2009, 1:57pm UTC](https://forum.kirupa.com/t/problem-with-button-function/294174/1 "2009-08-10T13:57:05Z")

</div>

Hi Friends,

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

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

```auto
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…
