View Full Version : Unload or dispose a Validator object
Mullenst
03-20-2009, 04:01 PM
Hi, I having some difficulty with String Validators - I have a form that popsup But when i close the popup and open the form again the validators are still in active/memory (outlined in red)
Is there any way to reset the validator every time i open the form..
code
private function NameStringValidator():void
{
_formNameValidator = new StringValidator();
with (_formNameValidator){
id = "NameCheck"; source = _textBoxName; property = "text";
requiredFieldError="This Name field requires a valid name.";
}
}
Peter Cowling
03-20-2009, 10:57 PM
I having some difficulty with String Validators - I have a form that popsup But when i close the popup and open the form again the validators are still in active/memory (outlined in red)
Can you explain this some more. Do you have:
a form in a popup
a popup error message
a form in a popup and another form
etc.
Mullenst
03-21-2009, 12:21 PM
yes sorry.. first of all I’m popping up a titlewindow with a form control inside. the form has three text fields and two buttons. I'm string validating 2 fields FormName and FormPlural - Most of what i'm reading is that I’ll have to replace the validator object - but as this titlewindow/form is predominant throughout the application - in its own class - i like to reuse it as much as possible - so is it possible that any time i save the contents of the form and remove the popup the form is disposes and when i need it i can just create the objects again..
Peter Cowling
03-21-2009, 12:41 PM
You can work with the 'enabled' property of the validator. You want to make sure that you have enabled set to true only when the titlewindow is active. There are two ways of doing this:
test for the presence of the titlewindow and match that to the enabled value.
act off user actions i.e. popup titlewindow -> switch to true, close the titlewindow -> switch to false.
Mullenst
03-24-2009, 07:29 PM
_titleWindow.addEventListener(FlexEvent.INITIALIZE , intForm);
_titleWindow.addEventListener(FlexEvent.REMOVE, closeForm);
private function closeForm (event:Event):void
{
_formNameValidator.enabled = false;
}
private function intForm (event:Event):void
{
_formNameValidator.enabled = true;
}
I've added this but the validator is still active
wvxvw
03-24-2009, 10:30 PM
I'd think of dispatching "valid" event from the validator upon opening the form, so, that the fields will come back to the normal state once the form is visible again.
Boris28
03-24-2009, 11:03 PM
you should try to use the required property
private function closeForm (event:Event):void
{
_formNameValidator.required = false;
}
private function intForm (event:Event):void
{
_formNameValidator.required = true;
}
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.