Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
var arr1:Array = new Array(); arr1.push(item1); arr1.push(item2); arr1.push(item3);
then arr1 and its elements get passed to other functions is there a way to know the index of an item in the array?
GetParentArrayIndex(item2) would give me 1;
Array's have built in functionality for this, myArray.indexOf(obj)
Add a comment
presumably you set a function like:
public function GetParentArrayIndex(item:Object):int { for(var i=0; i<arr1.length; i++){ if(arr1[i] == item){ return i; } } return -1 //Item not found }
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.