creating a label from a button click

I have one button, that will check if my textfield is filled. If it’s not, it will create a label for me, but isn’t working. So please guys, tell me why =).

A lil bit of my code:

contentOfTextField = createTextField(400, 200, 400, 30, contentOfTextField, 20);	
			
			if(createButton(620, 500, 100, 30, "Confirm")) {
				if(contentOfTextField.Length == 0) {
						createLabel(400, 100, 300, 30, "Please, put an user name!");
					
				}
				else {
					confirm = true;
				}
			}

Thank you!

Your way only display the label a single frame (or even less). Declare a global variable private var showLabel : boolean = false;. Change your code to:

contentOfTextField = createTextField(400, 200, 400, 30, contentOfTextField, 20);

     if(createButton(620, 500, 100, 30, "Confirm")) {
      if(contentOfTextField.Length == 0) {
             showLabel = true;
      }
      else {
          confirm = true;
      }
     }
     if(showLabel)
         createLabel(400, 100, 300, 30, "Please, put an user name!");