Created
May 24, 2011 21:13
-
-
Save bclinkinbeard/989706 to your computer and use it in GitHub Desktop.
Switch on type
This file contains 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
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