# Duplicate instance names

**URL:** https://forum.kirupa.com/t/duplicate-instance-names/145126
**Category:** Uncategorized
**Created:** [April 20, 2005, 3:04am UTC](https://forum.kirupa.com/t/duplicate-instance-names/145126 "2005-04-20T03:04:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bluerattle](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@bluerattle](https://forum.kirupa.com/u/bluerattle)
#### Post date: [April 20, 2005, 3:04am UTC](https://forum.kirupa.com/t/duplicate-instance-names/145126/1 "2005-04-20T03:04:27Z")

</div>

I haven’t seen much to explanation of this in any Flash documentation,  
but maybe someone knows more about this. Initially I was trying to  
fix a buggy application. The app is fixed now, but I’m still curious.

I have an app that defines some object instances (buttons and movie clips)  
in various frames and on various levels of a timeline. For any object that  
needs to be manipulated by AS, I give it an instance name.

However, there’s no safeguard against giving several instances the same  
name. So, I experimented with giving two buttons, on different  
layers and different frames, the same instance name (“playbtn”). Then I defined an event handler:

playbtn.onRelease = function () {  
gotoAndPlay(1);  
}

Turns out that the resulting app runs, but only one of the buttons is enabled. It’s not clear what rule decides the “winner”. I didn’t try every combination of frame/layer precedence.

Does anyone have any insight into how ActionScript 2 deals with instance  
names? Is there a way to reference an particular frame or layer when  
accessing an instance, or only by its name? And is there a documented  
look-up order?
