/ Published in: ActionScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// simpleStringMaker takes any string, and converts it to a simple, jpg-friendly name. simpleStringMaker = function ( thestring, extension ) { newstring = ""; // Init for ( i = 0; i < thestring.length; i++ ) { // Loop through the string 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) ) { 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. } } trace( newstring + extension ); // Return } simpleStringMaker ( "It's 419 : Gotta Minute..?!", ".jpg" ); // Test