Utils.as 490 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * ...
  3. * @author Default
  4. * @version 0.1
  5. */
  6. package string {
  7. public class Utils {
  8. public function Utils() {
  9. }
  10. static public function get_colour( col:String ) : Number
  11. {
  12. if( col.substr(0,2) == '0x' )
  13. return Number(col);
  14. if( col.substr(0,1) == '#' )
  15. return Number( '0x'+col.substr(1,col.length) );
  16. if( col.length==6 )
  17. return Number( '0x'+col );
  18. // not recognised as a valid colour, so?
  19. return Number( col );
  20. }
  21. }
  22. }