Posted By


aludwig on 06/09/11

Tagged


Statistics


Viewed 173 times
Favorited by 0 user(s)

Related snippets


simpleStringMaker


/ Published in: ActionScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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

You need to login to post a comment.