# Dynamic menu - wrong buttons references or something

**URL:** <https://forum.kirupa.com/t/dynamic-menu-wrong-buttons-references-or-something/309454>\
**Category:** Uncategorized\
**Created:** [May 15, 2010, 4:54pm UTC](https://forum.kirupa.com/t/dynamic-menu-wrong-buttons-references-or-something/309454 "2010-05-15T16:54:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hommer](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@Hommer](https://forum.kirupa.com/u/Hommer)\
**Post date:** [May 15, 2010, 4:54pm UTC](https://forum.kirupa.com/t/dynamic-menu-wrong-buttons-references-or-something/309454/1 "2010-05-15T16:54:56Z")

</div>

Hello Flashers.

I’m trying to make a dynamic menu.  
I load four buttons to the stage and applie code to each of the buttons. But it’s only the last button loaded, that responds to onRollOver/onRollOut  
If I roll over the other buttons it’s the last buttons that reacts all the time.  
I just can’t see what’s wrong. I’m sure it pretty simple.  
Here’s the code:

```auto
for (var i:Number = 0; i<4; i++) {
	btnRef = "button"+i;

	btnLoader.attachMovie("btnClip",btnRef,btnLoader.getNextHighestDepth(),{_x:10, _y:i*50});
	btnLoader[btnRef].picTypeTxt.txt.text = this["picType"+portfolioTypesItt+"DK"];
	btnLoader[btnRef].overBtn = false;

	btnLoader[btnRef].btn.onRollOver = function() {
		btnLoader[btnRef].play();
		btnLoader[btnRef].overBtn = true;
	};
	btnLoader[btnRef].btn.onRollOut = function() {
		btnLoader[btnRef].overBtn = false;
	};
	btnLoader.onEnterFrame = function() {
		if (btnLoader[btnRef].overBtn == false) {
			btnLoader[btnRef].prevFrame();
		}
	};
}

```

Can anyone help me, please? I’ve added the .fla-file if anyone would look at it.  
Thanks guys.
