private function swapOutCharacterChunk ( //used because some numbered assets have the number in the MIDDLE of them. baseWord:String, search:String, replace:String ) { var halves:Array = baseWord.split(search); if (halves.length > 2) { throw new Error("replaces only ONE") }; return ( halves[0] + replace + halves[1] ); } //example: var originalText = "GetThis#Thingy"; var newText:String = swapOutCharacterChunk(originalText, "#", "3"); trace("newText==" + newText); //output: newText==GetThis3Thingy //not overly useful. //should really make your artists adhere to naming conventions than do this.
Wednesday, November 7, 2012
swap out character in middle of string
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment