The following function will use hitTestObject
and the child indices of the objects to determine if obj1 is "in front of" obj2.
function isInFrontOf(obj1:DisplayObject, obj2:DisplayObject):Boolean{
return obj1.hitTestObject(obj2) && (obj1.parent.getChildIndex(obj1) > obj2.parent.getChildIndex(obj2));
}
Important note: This will only work if both objects have the same parent. You absolutely can rework the function to allow for different parents, but I'll leave that up to you.