PDA

View Full Version : how to feed a Text Box array?


rodrigoalex
09-13-2009, 02:18 PM
Hello guys, I would like to feed a text box dynamically, seeing as I called:

import mx.controls.Text;

public var msgError: Text;

public function CheckForm (): void (
msgErro = new Text ();
imgErro = new Image ();
msgErro.setStyle ( "right", "50");
msgErro.setStyle ( "top", "55");
msgErro.width = 200;
msgErro.height = 50;

imgErro.source = ".. / images/ warning.png";
imgErro.setStyle ( "right", "5");
imgErro.setStyle ( "top", "55");

canvascontract.addChild (msgErro);
canvascontract.addChild (imgErro);

if (comp_na.text == "") {
msgErro.text = "Sorry, but the field Company Name can not be empty";
} else if (email_cont.text == "") {
msgErro.text = "Sorry, but the Contact Email field can not be empty";
} Else if (email_cont.text.indexOf ("@") == -1) {
msgErro.text = "Sorry, but this is not a valid email";
}
}

But the problem is that it supports the text, ie not erase another message and then put the new, simply appears on top of another, how could fix this?

sydd_hu
09-13-2009, 07:48 PM
But the problem is that it supports the text, ie not erase another message and then put the new, simply appears on top of another, how could fix this?

Sorry, i don't understand it...

But if you want error text this is the easiest way to do it:
(you dont need any extra textboxes to display error messages)

if (comp_na.text == "") {
comp_na.errorString = "Sorry, but the field Company Name can not be empty";
} else if (email_cont.text == "") {
email_cont.errorString = "Sorry, but the Contact Email field can not be empty";
} Else if (email_cont.text.indexOf ("@") == -1) {
email_cont.errorString = "Sorry, but this is not a valid email";
} else {comp_na.errorString = ""}
}

note: to make it work comp_na needs to be TextArea or TextInput