Skip to content

Instantly share code, notes, and snippets.

@Nutrox
Created December 18, 2010 22:25
Show Gist options
  • Save Nutrox/746932 to your computer and use it in GitHub Desktop.
Save Nutrox/746932 to your computer and use it in GitHub Desktop.
AS3 isDefinition() function
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