Skip to content

Instantly share code, notes, and snippets.

@bclinkinbeard
Created May 24, 2011 21:13
Show Gist options
  • Save bclinkinbeard/989706 to your computer and use it in GitHub Desktop.
Save bclinkinbeard/989706 to your computer and use it in GitHub Desktop.
Switch on type
var s:Sprite = new Sprite();
var mc:MovieClip = new MovieClip();
var b:Button = new Button();
var arr:Array = [ s, mc, b, this ];
for each( var obj:Object in arr )
{
switch( obj.constructor )
{
case Sprite:
trace( "Found a Sprite" );
break;
case MovieClip:
trace( "Found a MovieClip" );
break;
case Button:
trace( "Found a Button" );
break;
default:
trace( "WTF" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment