OK, I confirmed how binding basically applies to the SetProperty tag but
doesn't apply to the target of the SetProperty tag.  We've filed a bug
and will see what happens.

Matt

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Matt Chotin
Sent: Tuesday, April 25, 2006 11:42 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: mx:States and databinding issue

Glad you could get the workaround going.  I'll forward this into the
team and see if they have any thoughts.

Matt

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of sof4real03
Sent: Tuesday, April 25, 2006 7:13 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: mx:States and databinding issue

Matt,

After a ton of debugging I finally was able to change the value of the
button in the State via actionscript and not through binding with the
SetProperty tag.

public function formsValid(...args:Array):Boolean
{
for(var i:int = 0; i < args.length; i++)
{
  if( args[i] == false )
      return false;                       
}
  parentDocument.addClientBtn.enabled = true;                       
  return true;
}                 

<mx:states>
<mx:State name="default" id="defaultCCView">
<mx:SetProperty target="{parentDocument.addClientBtn}" name="enabled"
value="{formsValid(personalDetails.formValid,contactDetails.formValid)
}"/>
<mx:SetEventHandler target="{parentDocument.addClientBtn}"
name="click" handler="submitClientForm()"/>
</mx:State>
</mx:states>


Now I'm not sure if this is a databinding issue with States and
SetProperty tag, but this workaround isn't something I'd like to do in
the future. I hope someone can point something wrong in my code that
would make the state handle the databind correctly, but I just don't
see anything wrong.

Thanks,
Sof

--- In flexcoders@yahoogroups.com, "sof4real03" <[EMAIL PROTECTED]> wrote:
>
> I'm at a loss here, Anybody having any issues with binding in States?
>
> --- In flexcoders@yahoogroups.com, "sof4real03" <soubraham2@> wrote:
> >
> > After tracing my code, I'm sure that the event is being propagated,
> > but the button still doesn't become enabled even when the forms are
> > valid. Could it be the issue of creating this state on the
component's
> > parent?
> >
> > --- In flexcoders@yahoogroups.com, "sof4real03" <soubraham2@> wrote:
> > >
> > > You are correct, the formsValidationChange event is bound for the
> > > formvalid property of the component.
> > >
> > > [ChangeEvent("formValidChanged")]
> > > public function get formValid():Boolean
> > > {
> > >       return _formValid;
> > > }
> > >            
> > > public function set formValid( formValid:Boolean ):void
> > > {
> > >       setFormValid( formValid );
> > > }
> > >
> > > private function setFormValid( formValid:Boolean ):void
> > > {
> > >       if ( formValid != _formValid )
> > >       {
> > >             _formValid = formValid;
> > >             dispatchEvent(new Event("formValidChanged"));
> > >       }
> > > }
> > >
> > >
> > > I've put Alerts in the formsValid function and it's getting to the
> > > function, but it doesn't seem to be recieving the
> > > "formValidationChange" event everytime it's set to a new value.
I'm at
> > > a loss...
> > >
> > > If I don't use a state and put in this button on the page
initially
> > > all is good.
> > > --- In flexcoders@yahoogroups.com, "Matt Chotin" <mchotin@> wrote:
> > > >
> > > > What is formValidationChanged the event on?  The formValid
> property I
> > > > hope?  Are you sure you're not going into the formsValid method?
>  Try
> > > > naming the arguments array to something different like args,
> arguments
> > > > is a reserved word and may be acting funky here (though it
> should work
> > > > correctly in this case I think).
> > > >
> > > > Matt
> > > >
> > > > -----Original Message-----
> > > > From: flexcoders@yahoogroups.com
> > [mailto:[EMAIL PROTECTED] On
> > > > Behalf Of sof4real03
> > > > Sent: Monday, April 24, 2006 9:03 PM
> > > > To: flexcoders@yahoogroups.com
> > > > Subject: [flexcoders] mx:States and databinding issue
> > > >
> > > > I have a custom form component that broadcasts an event every
> time the
> > > > form changes validation states:
> > > >
> > > > ContactDetails.mxml:
> > > >
> > > > [ChangeEvent("formValidationChanged")]
> > > >
> > > > Now the parent component of "ContactDetails" is
> > > > CreateClientProfile.mxml and it uses an accordian to
instantiate the
> > > > ContactDetails form.
> > > >
> > > > Finally "CreateClientProfile" is a state of another component.
> > > >
> > > > Ok, so in ContactDetails, I have the following code:
> > > >
> > > > <mx:states>
> > > > <mx:State name="default" id="defaultCCView">
> > > > <mx:AddChild target="{parentDocument.clientPanelControl}">
> > > > <mx:Button id="addClientBtn" label="Add My Client"/>
> > > > </mx:AddChild>
> > > > <mx:SetProperty target="{addClientBtn}" name="enabled" value="{
> > > > formsValid(personalDetails.formValid,contactDetails.formValid)
}"/>
> > > > <mx:SetEventHandler target="{addClientBtn}" name="click"
> > > > handler="submitClientForm()"/>
> > > > </mx:State>
> > > > </mx:states>
> > > >
> > > > <mx:Script>
> > > > <![CDATA[
> > > >            
> > > > public function formsValid(...arguments:Array):Boolean
> > > > {
> > > >  for(var i:int = 0; i < arguments.length; ++i)
> > > >  {
> > > >   if( arguments[i] == false )
> > > >   {
> > > >     return false;
> > > >   }
> > > >  }
> > > >  return true;
> > > > }
> > > >
> > > > So, in the CreateClientProfile.mxml, I create a button on it's
> parent
> > > > container, ClientPanel.mxml.
> > > >
> > > > ClientPanel -> CreateClientProfile -> ContactDetails
> > > >
> > > > Eventhough I'm broadcasting the "FormValidationChange" event
> from the
> > > > ContactDetails component it doesn't get picked up from the state
> that
> > > > creates the button though it's using databinding on the
formsvalid
> > > > function. Any insight?
> > > >
> > > > Thanks,
> > > > Sof
> > > >      
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Flexcoders Mailing List
> > > > FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > > Search Archives:
> > > > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > > Yahoo! Groups Links
> > > >
> > >
> >
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to