Created
May 14, 2011 21:38
-
-
Save ThomasBurleson/972665 to your computer and use it in GitHub Desktop.
AS3 Functional Programming to Convert String list to BitFlags
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
"properties,size,displayList" | |
.split(",") | |
.map( function ( item:String, index:int, array:Array ):uint { | |
switch( StringUtil.trim( item ) ) | |
{ | |
case "displaylist": return InvalidationFlags.DISPLAY_LIST; | |
case "size" : return InvalidationFlags.SIZE; | |
case "properties" : return InvalidationFlags.PROPERTIES; | |
default : throw new Error( "Unsupported invalidation option specified." ); | |
} | |
}) | |
.forEach( function ( invalidationFlag:uint, index:int, array:Array ):void { | |
invalidationFlags = invalidationFlags | invalidationFlag; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment