# Using a simple function to display a button but then

**URL:** <https://forum.kirupa.com/t/using-a-simple-function-to-display-a-button-but-then/225179>\
**Category:** Uncategorized\
**Created:** [May 9, 2007, 2:02pm UTC](https://forum.kirupa.com/t/using-a-simple-function-to-display-a-button-but-then/225179 "2007-05-09T14:02:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ALGORYTHM](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ALGORYTHM](https://forum.kirupa.com/u/ALGORYTHM)\
**Post date:** [May 9, 2007, 2:02pm UTC](https://forum.kirupa.com/t/using-a-simple-function-to-display-a-button-but-then/225179/1 "2007-05-09T14:02:49Z")

</div>

here’s something a little frustrating!

simply speaking,

create a button, create a movie clip with two frames.

place a button instance in frame 2.

place a mc instance on the stage.

create another instance of the button to change the movie clip instance to frame two.

the button in the movie clip is pressed and executes a function.

here’s the code

```auto
// create the button to show the button!
_root.button_instance_2.onPress = function() {
	buttonClick1();
};
// set the movie clip instance frame
function buttonClick1() {
	_root.button_container_instance.gotoAndStop(2);
}
// create the function, target the button instance within the movie clip instance.
_root.button_container_instance.button_instance_1.onPress = function() {
	buttonClick2();
};
function buttonClick2() {
	trace("button hit");
}

```

this doesn’t work!

if, however, i use the same code on a movie clip that has only one frame it will work fine. do i need to tell the function to target the button instance any more specifically than that?

:puzzle:

thanks in advance guys
