timgerr, it in your own code...:

> > var validateString:StringValidator = new
> > StringValidator();



PS: Use Ryan's example (Dictionary) if you prefer objects instead of strings
as your key in the dictionary or object variable


On Thu, Nov 6, 2008 at 5:43 PM, timgerr <[EMAIL PROTECTED]> wrote:

>   No I am again lost. Sorry for the confusion, but I might need a code
> example,
>
> globalValidators["validatorID_" + formItem[0].id] = validateString ;
> What is an example of validateString .
>



>
> Thanks for the help, I am trying to learn a more advanced way to doing
> things.
>
> Thanks again,
> timgerr
>
> --- In [email protected] <flexcoders%40yahoogroups.com>, "Fotis
> Chatzinikos"
> <[EMAIL PROTECTED]> wrote:
> >
> > Hi timgerr,
> >
> > try the following:
> >
> > var globalValidators:Object = new Object() ;
> >
> > inside the dynamically validators function do the following:
> >
> > globalValidators["validatorID_" + formItem[0].id] = validateString ;
> >
> > now when you need the validator (and you know the component (and its
> id) you
> > can get the validator:
> >
> > StringValidator sv = globalValidators["validatorID_" +
> knownFormItem.id] as
> > StringValidator
> >
> >
> > On Thu, Nov 6, 2008 at 6:38 AM, timgerr <[EMAIL PROTECTED]> wrote:
> >
> > > Not sure how to do that. If the validators are created dynamically:
> > >
> > > var c:UIComponent = formItem[0];
> > > c.addEventListener(FocusEvent.FOCUS_OUT,UpdateItem);
> > > var validateString:StringValidator = new
> > > StringValidator();
> > > validateString.source = c;
> > > validateString.property = "text";
> > > validateString.required = formItem[0].parent.required;
> > > validateString.maxLength = formItem[0].maxChars - 10;
> > >
> > > How do I make an an associative array? Not sure what the id of the
> > > validator is.
> > >
> > > Thanks for the help,
> > > timgerr
> > >
> > > FYI, c is a UIComponent
> > >
> > >
> > > --- In [email protected] 
> > > <flexcoders%40yahoogroups.com><flexcoders%
> 40yahoogroups.com>,
> "Tracy
> > > Spratt" <tspratt@> wrote:
> > > >
> > > > Perhaps create an associative array of references to the validators?
> > > >
> > > > Tracy
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >
> > > > From: [email protected] 
> > > > <flexcoders%40yahoogroups.com><flexcoders%
> 40yahoogroups.com>
> [mailto:
> > > [email protected] <flexcoders%40yahoogroups.com> <flexcoders%
> 40yahoogroups.com>] On
> > > > Behalf Of timgerr
> > > > Sent: Wednesday, November 05, 2008 7:12 PM
> > > > To: [email protected] 
> > > > <flexcoders%40yahoogroups.com><flexcoders%
> 40yahoogroups.com>
>
> > > > Subject: [flexcoders] Get id of dynamic validator
> > > >
> > > >
> > > >
> > > > Hello, I have this form and I am createin dynamic validators for
> each
> > > > textinput. I cannot see how to get the validators id when I try and
> > > > validate the textinput boxes, here is my code:
> > > > <mx:Form width="370" id="userInfoForm">
> > > > <mx:FormItem label="First Name" required="true"
> > > > id="fname_25_string">
> > > > <mx:TextInput id="firstName" toolTip="First Name: Max Length 25
> > > > Characters"
> > > > maxChars="35" text="James"/>
> > > > </mx:FormItem>
> > > > <mx:FormItem label="Last Name" required="true" id="lname_25_string">
> > > > <mx:TextInput id="lastName" toolTip="Last Name: Max Length 25
> > > > Characters"
> > > > maxChars="35"/>
> > > > </mx:FormItem>
> > > > <mx:FormItem label="Email" required="true" id="Email__">
> > > > <mx:TextInput id="email" editable="false" toolTip="Cannot edit
> > > > this field"/>
> > > > </mx:FormItem>
> > > > <mx:FormItem label="Title" id="tit_25_string">
> > > > <mx:TextInput id="title" maxChars="35" toolTip="Title: Max
> > > > Length 25 Characters"/>
> > > > </mx:FormItem>
> > > > </mx:Form>
> > > >
> > > > So I do a creationcomplete to run a function to get a list of
> all the
> > > > textboxes:
> > > > private function GetChild(item:Object):void
> > > > {
> > > > var formItems:Array = item.getChildren();
> > > > // loop items and add values
> > > > for (var i:int = 0; i < formItems.length; i++)
> > > > {
> > > > // formItem
> > > > var formItem:Array = formItems[i].getChildren();
> > > > var c:UIComponent = formItem[0];
> > > > if(c.className.toString() == 'TextInput'){
> > > > var rtnID:String = c.id;
> > > > formItem[0].text = _performaReturnUsersData[rtnID];
> > > > /* adding an eventlistener (focuseEvent) to all textinput
> > > > */
> > > > c.addEventListener(FocusEvent.FOCUS_OUT,UpdateItem);
> > > > var validateString:StringValidator = new
> > > > StringValidator();
> > > > validateString.source = c;
> > > > validateString.property = "text";
> > > > validateString.required = formItem[0].parent.required;
> > > > validateString.maxLength = formItem[0].maxChars - 10;
> > > > }
> > > > }
> > > > }
> > > >
> > > > This function will go through an find textinput boxes then assign a
> > > > validator to them. So all is working but the problem is I have no
> > > > idea how to validate the data without knowing the id of the
> individual
> > > > instance of the validator.
> > > >
> > > > I have added a listener to the instances of the textinput called
> > > > UpdateItem, so here is the code:
> > > >
> > > > function UpdateItem(f:FocuseOut):void
> > > > {
> > > > trace(f.target.id);
> > > > // Not sure what to do here becuase I dont know the id of the
> > > > validator attached to the textinput
> > > > }
> > > >
> > > > How can I see if the textinput passes the validators?
> > > >
> > > > Thanks for the help,
> > > > timgerr
> > > >
> > >
> > >
> > >
> >
> >
> >
> > --
> > Fotis Chatzinikos, Ph.D.
> > Founder,
> > Phinnovation
> > [EMAIL PROTECTED],
> >
>
>  
>



-- 
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
[EMAIL PROTECTED],

Reply via email to