Don’t forget to instantiate Strings

Small wtf moment today. I forgot to instantiate / give a String variable a default value. After appending the string and tracing it, “null” was the first part that showed, see below:

  1. var test:String;
  2. test += "Test 1, 2, 3, 4...";
  3. trace(test);
  4. // output: "nullTest 1, 2, 3, 4..."

Fix:

  1. var test:String = "";

Oops! 🙂