Created
December 18, 2010 22:25
-
-
Save Nutrox/746932 to your computer and use it in GitHub Desktop.
AS3 isDefinition() function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.utils.describeType; | |
// | |
// trace( isDefinition(Sprite,"flash.display::Sprite") ); // true | |
// trace( isDefinition(Sprite,"flash.display::InteractiveObject") ); // true | |
// trace( isDefinition(Sprite,"flash.events::EventDispatcher") ); // true | |
// trace( isDefinition(Sprite,"flash.events::Event") ); // false | |
// | |
public function isDefinition( definition:Class, type:String ):Boolean { | |
var info:XML = describeType( definition ); | |
if( info.@name == type ) { | |
return true; | |
} | |
for each( var item:XML in info.factory.extendsClass ) { | |
if( item.@type == type ) { | |
return true; | |
} | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment