Is there a way to detect if my Vector is out-of-range before performing an action?
I tried
if (myVector[i] != null || myVector != undefined) {
// do stuff here
}
But I am getting an out-of-range error.
Is there a way to detect if my Vector is out-of-range before performing an action?
I tried
if (myVector[i] != null || myVector != undefined) {
// do stuff here
}
But I am getting an out-of-range error.
You need to check if the index is <= the length of the vector, and change the order of your tests. I'm not a Flash guy, but in most C-like languages, it'll look like this:
if (myVector != undefined /* Make sure the vector isn't null*/ && i < myVector.length() /*Make sure it's in range*/ && myVector[i] != null){
// Do stuff here
}