Tuesday, November 20, 2012
constructor length problem
Article found here to solve problem via hack:
http://jacksondunstan.com/articles/398
Wednesday, November 7, 2012
swap out character in middle of string
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.
Friday, November 2, 2012
using the WITH keyword in ActionScript AS3
var retVal:stuff = new stuff(); with(retVal) { a = 1; b = 2; c = 3; } trace("retVal.a == " + retVal.a); trace("retVal.b == " + retVal.b); trace("retVal.c == " + retVal.c); internal class stuff { public var a:int; public var b:int; public var c:int; public function stuff():void{} } //output: /* retVal.a == 1 retVal.b == 2 retVal.c == 3 */Not sure I find this useful. Saves typing, but I am not sure how I feel about debugging code written like this. Also, intellisense in flashDevelop doesn't appreciate it. Maybe I will use the with keyword... Depends on how much typing I need to save and what makes things more readable.
Subscribe to:
Posts (Atom)