I've written a helper class for this:
package de.richinternet.utils
{
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedSuperclassName;
public class ClassUtils
{
public static function isSubclassOf(classA:Class,
classB:Class):Boolean
{
if (classA == classB) return true;
if (getQualifiedSuperclassName(classA) == null)
throw new ArgumentError("Cannot determine supertype for " + classA);
while (classA != Object)
{
var s:String =
getQualifiedSuperclassName(classA);
var c:Class = getDefinitionByName(s) as
Class
if (c is Class)
{
return isSubclassOf(c, classB);
}
return false;
}
return false;
}
}
}
Dirk.
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of Sergey Kovalyov
> Sent: Wednesday, July 19, 2006 11:03 AM
> To: [email protected]
> Subject: [flexcoders] Class instance inheritance check
>
> Hi All!
>
> Imagine, I have the Class instnace as a function parameter.
>
> function myFunction(clazz : Class) {
> ...
> }
>
> How to check that clazz is inherited from some other class (e. g.
> UIComponent). Sure, I can create instnace.
>
> if (new clazz() is UIComponent) {
> ...
> }
>
> But this approach seems not good as for me. Any ideas?
>
> Sergey.
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/