# "Getting an Index Position from an Array" doubt

**URL:** <https://forum.kirupa.com/t/getting-an-index-position-from-an-array-doubt/71246>\
**Category:** flash\
**Created:** [November 22, 2004, 6:22pm UTC](https://forum.kirupa.com/t/getting-an-index-position-from-an-array-doubt/71246 "2004-11-22T18:22:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crop](https://avatars.discourse-cdn.com/v4/letter/c/a587f6/32.png) [@crop](https://forum.kirupa.com/u/crop)\
**Post date:** [November 22, 2004, 6:22pm UTC](https://forum.kirupa.com/t/getting-an-index-position-from-an-array-doubt/71246/1 "2004-11-22T18:22:31Z")

</div>

Hello

I’ve used the tutorial I found in the tutorials section for Flash MX

[http://www.kirupa.com/developer/actionscript/tricks/indexposition.htm](http://www.kirupa.com/developer/actionscript/tricks/indexposition.htm)

but I’m stuck with a question, since, for the project I’m working, this keeps returning -1.  
Assuming this:

--------- as in the tutorial ------------  
Array.prototype.getIndex = function(data) {  
for (i=0; i\<this.length; ++i) {  
if (this\* == data) {  
return i;  
}  
}  
return -1;  
};  
resources = new Array(“a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”);  
location = resources.getIndex(“e”);  
trace(location);  
----------- xxx -----------------------

if you want to find the location of your data you just type it when you are calling the function.  
My problem: I can’t seem to make it work to find the location of a “composed” data, that is, in an array with (“da”,"db,“dc”,“dd”,“de”,“df”) I can only get the index of “de” if I type it directly. If I try using this:

Choice = “d”+letter;  
location = resources.getIndex(Choice);  
trace(location);

It always return -1

Why? I’m I doing something wrong?

Thanks for the tutorial and thanks for any help possible.

Crop
