How to solve null error
Program is to turn standard time to traditional time. Ex 24:23 is 12:23. But instead of that when I run the the program is just gives me null.
// Name:
// Date:
// Purpose: To convert standard time to traditional time
// This line makes the button, btnConvert wait for a mouse click
// When the button is clicked, the convertTime function is called
btnConvert.addEventListener(MouseEvent.CLICK, convertTime);
// This line makes the textinput wait for a mouse click
// When this component is clicked, the clearLabels function is called
txtinStandard.addEventListener(MouseEvent.CLICK, clearLabels);
// Declare Global Variables
var traditionalTime:String; // traditional time
// This is the convertTime function
// e:MouseEvent is the click event experienced by the button
// void indicates that the function does not return a value
function convertTime(e:MouseEvent):void
{
// declare the variables
var standardTime:String; // standard time entered by user
standardTime = txtinStandard.text; // get standard time from user
convertToTraditional(standardTime); // call the convertToTraditional function
// output an appropriate message in the label
lblOutput.text = standardTime + " is equivalent to " + traditionalTime;
}
// This is function convertToTraditional
// s – is the standard time
// It determines the traditional time based on the value of s
function convertToTraditional(s:String){
// write the code here
if (s == 0){
lblOutput.text += 12;
}
else if (s == "1"){
lblOutput.text += "1";
}
else if (s == "2"){
lblOutput.text += "2";
}
else if (s == "3"){
lblOutput.text += "3";
}
else if (s == "4"){
lblOutput.text += "4";
}
else if (s == "5"){
lblOutput.text += "5";
}
else if (s == "6"){
lblOutput.text += "6";
}
else if (s == "7"){
lblOutput.text += "7";
}
else if (s == "8"){
lblOutput.text += "8";
}
else if (s == "9"){
lblOutput.text += "9";
}
else if (s == "10"){
lblOutput.text += "10";
}
else if (s == "11"){
lblOutput.text += "11";
}
else if (s == "12"){
lblOutput.text += "12";
}
else if (s == "13"){
lblOutput.text += "1";
}
else if (s == "14"){
lblOutput.text += "2";
}
else if (s == "15"){
lblOutput.text += "3";
}
else if (s == "16"){
lblOutput.text += "4";
}
else if (s == "17"){
lblOutput.text += "5";
}
else if (s == "18"){
lblOutput.text += "6";
}
else if (s == "19"){
lblOutput.text += "7";
}
else if (s == "20"){
lblOutput.text += "8";
}
else if (s == "21"){
lblOutput.text += "9";
}
else if (s == "22"){
lblOutput.text += "10";
}
else if (s == "23"){
lblOutput.text += "11";
}
else if (s == "24"){
lblOutput.text += "12";
}
}
// This is the clearLabels function
// e:MouseEvent is the click event experienced by the textInput
// void indicates that the function does not return a value
function clearLabels(e:MouseEvent):void
{
lblOutput.text = "";
txtinStandard.text = "";
}
