# How to compare array index to display object?

**URL:** <https://forum.kirupa.com/t/how-to-compare-array-index-to-display-object/282181>\
**Category:** flash\
**Created:** [February 18, 2009, 5:41pm UTC](https://forum.kirupa.com/t/how-to-compare-array-index-to-display-object/282181 "2009-02-18T17:41:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Keel](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@John\_Keel](https://forum.kirupa.com/u/John_Keel)\
**Post date:** [February 18, 2009, 5:41pm UTC](https://forum.kirupa.com/t/how-to-compare-array-index-to-display-object/282181/1 "2009-02-18T17:41:18Z")

</div>

Assume I have an array with references to different display objects on the stage. The display objects do not have any other explicit references except for the array indexes. How do I evaluate if a certain index of the array is a reference to a certain display object?

Some code to clarify:

Assume:  
objArr[1] = dispObj1;  
objArr[2] = dispObj2;  
objArr[3] = dispObj3;

function performSomeActionOnObj( ):void  
{[INDENT] for( var i:int = 0; i \< objArr.length; i ++)  
{[INDENT]// problematic step  
// how do I compare array index to display object  
// when display object does not have an explicit  
// reference within the display list?  
if( [COLOR=Red]**objArr[i] == dispObj2**[/COLOR] [COLOR=Red] **/_???_/** [/COLOR] )  
[/INDENT][/INDENT][INDENT][INDENT] {  
[/INDENT][/INDENT][INDENT][INDENT][INDENT] dispObj2.foo( );  
[/INDENT][/INDENT][/INDENT][INDENT][INDENT] }  
[/INDENT][/INDENT][INDENT][INDENT] else  
[/INDENT][/INDENT][INDENT][INDENT] {  
[/INDENT][/INDENT][INDENT][INDENT][INDENT] return;  
[/INDENT][/INDENT][/INDENT][INDENT][INDENT] }  
[/INDENT][/INDENT][INDENT] }  
[/INDENT]}
