Difference between empty string and zero value

Type comparisons between text field string values and integers can be bothersome as an empty string would trace as 0. Undeclared integers always default to zero.

textfield.text = "";
trace(int(textfield.text)); // 0

If you need to check whether a textfield is empty or if it contains the number zero, use a boolean.

if(Boolean(textfield.text)) {
// textfield contains some input
if(textfield.text == "0") {
// textfield contains the zero character
}
}

Splitting string with delimiters

Splitting a string with delimiters, i.e. commas, into an array was easy.

I had an XML-file with multiple possible values for one start value. These would be used to populate a drop down:

<startValue>1</startValue>
<endValue>1,2,3,4,5</endValue>

Alas, I needed to split the endValue property into an array:

var tmp:String = xmlList.endValue.text();
var array:Array = tmp.split(",");
trace(array);