PDA

View Full Version : Weird result with getting index of array element...


rickid
09-03-2006, 11:21 PM
Hi,

For some reason the following code causes the contents of my scrollpane to be offset by 1 pixel. I can't understand why it has anything to do with this but I've tested it thoroughly and it's definitely this code.

Is there another way to get the index of an element in the array other than this:


Array.prototype.getIndex = function(data) {
for (i=0; i<my_array.length; ++i) {
if (this[i] == data) {
return i;
}
}
return -1;
}
myindex = my_array.getIndex("myarrayelement")

Thanks for your help