i have an filter array containing one drop shadow filter. trace is returning -1 instead of 0 for indexOf after it is tracing that the array contains the object. please explain.
trace(filterObject);
trace(displayObject.filters);
trace(displayObject.filters.indexOf(filterObject));
//outputs:
//
// [object DropShadowFilter]
// [object DropShadowFilter]
// -1
Looks like filters are copied behind the scenes when you apply them. That is, the filter stored in the filters array is not the same object you passed. Since indexOf compares object reference, you get -1, indicating the object you passed to the method is not contained in the array.
This little snippet shows this more clearly:
It’s worth noting that every BitmapFilter has a clone() method, which I assume is being called internally to make a fresh copy of the object.