m90
June 14th, 2009, 03:11 PM
Hello!
I have a problem. If I say "obj is Object" it will always return true as everything extends Object. Can I somehow find out if an object is exactly an instance of the specified class?
In my case I have both Sprites and MovieClips in the display list. Now I'd like to loop through the list and get the Sprites only. But if I say "obj is Sprite" this is of course true for the MovieClips as well!
Of course I can do:
if (obj is Sprite && !(obj is MovieClip)){
}
but I was wondering how to tackle this if the class you're looking for is "way up the ladder" and has lots of subclasses?
Any tip?
Thanks!
I have a problem. If I say "obj is Object" it will always return true as everything extends Object. Can I somehow find out if an object is exactly an instance of the specified class?
In my case I have both Sprites and MovieClips in the display list. Now I'd like to loop through the list and get the Sprites only. But if I say "obj is Sprite" this is of course true for the MovieClips as well!
Of course I can do:
if (obj is Sprite && !(obj is MovieClip)){
}
but I was wondering how to tackle this if the class you're looking for is "way up the ladder" and has lots of subclasses?
Any tip?
Thanks!