As a workaround that might help you pinpoint the problem I would try the following -
You might find out it's not the same data object...
On second thought, it would probably make more sense to always go through the event's target (or target's owner) dataProvider.
That way the function would be more reuseable (even if it doesn't have to be currently).
Are you sure index is equal to zero ? If I remember correctly, the row index is the , well, row index of the rendered item. So if you scroll up 3 renderers and click the top one, the row index will be 0, but the actual index in the collection will be 3. I might be wrong about this, but you could always do something like this to put the issue to rest.
var selectedObject:Object = event.currentTarget.selectedItem;
Try that and see if you have any more problems.
Perhaps check that the elements in the ArrayCollection are actually User objects. The statement:
instructors.getItemAt(index) as User
will return null if that item is not actually a User object. I believe by default the WebService returns objects that are instances of ObjectProxy, which have all the same properties as your actual object, but they may not be actual "User" instances in your case.
I traced the object directly from the ArrayCollection and the print statement was [object User].
I also confirmed I'm getting it from the right index. This is maddening.
What is the exact text and stacktrace of the error?
Thanks for your help. I had to dig but someone on this thread answered the problem, it just wasn't readily apparent. The error was a type coercion error in reality but the array collection returning null for bad casts masked the problem. I had to write my own converter. The objects are identical but from different web services so the packages are different. If you have a better way, I am all ears. Thanks.
Sent from my iPhone