Posted By

aludwig on 06/09/11


Tagged

String


Versions (?)

simpleStringMaker


 / Published in: ActionScript
 

  1. // simpleStringMaker takes any string, and converts it to a simple, jpg-friendly name.
  2.  
  3. simpleStringMaker = function ( thestring, extension ) {
  4. newstring = ""; // Init
  5. for ( i = 0; i < thestring.length; i++ ) { // Loop through the string
  6. if ( (thestring.charCodeAt(i) > 47 && thestring.charCodeAt(i) < 58) || (thestring.charCodeAt(i) > 96 && thestring.charCodeAt(i) < 123) || (thestring.charCodeAt(i) > 64 && thestring.charCodeAt(i) < 91) ) {
  7. newstring += thestring.charAt(i).toLowerCase(); // If the string's char is a letter (upper or lower case) or a number, add it to newstring. Ignore it if it's anything else. Also, set the char to lower case either way.
  8. }
  9. }
  10. trace( newstring + extension ); // Return
  11. }
  12. simpleStringMaker ( "It's 419 : Gotta Minute..?!", ".jpg" ); // Test

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: aludwig on June 9, 2011

The Actionscript version of simpleStringMaker has an optional argument to add a file extension to the end of the output string.

Posted By: aludwig on June 9, 2011

The Actionscript version of simpleStringMaker has an optional argument to add a file extension to the end of the output string.

You need to login to post a comment.