-- Matthew
On 4/19/05, joao_m_fernandes <[EMAIL PROTECTED]> wrote:
Thanks,
It worked but I was hoping that we could define the same logic with
AS as we do in MXML. I see we can't.
Joćo Fernandes
--- In flexcoders@yahoogroups.com , Joe Berkovitz <[EMAIL PROTECTED]> wrote:
> Joao,
>
> The trouble here is that you are only evaluating the condition once,
> when you create the button.
>
> You will need to add a listener to the dataProvider(s) that causes the
> condition to be reevaluated every time the data changes. As in:
>
> btn =
ctrlbar.createChild(mx.controls.Button,undefined,{label:label});
> someList.dataProvider.addEventListener
> ('modelChanged',
> mx.utils.Delegate.create(this, checkButtonEnable));
>
> private function checkButtonEnable():Void
> {
> btn.enabled = (somelist.dataProvider.length == 3);
> }
>
> joao_m_fernandes wrote:
> >
> > Ali,
> >
> > I'm creating a button like this:
> > <mx:Script>
> > <![CDATA[
> > var btn;
> > function create_btn_save(label,funct){
> > ctrlbar.destroyAllChildren();
> > btn = ctrlbar.createChild(mx.controls.Button,undefined,{label:label});
> > btn.addEventListener('click',mx.utils.Delegate.create(this,funct));
> > btn.enabled = (somelist.dataProvider.length == 3 &&
> > otherlist.dataProvider.length == 3);
> > }
> >
> > ]]>
> >
> > I get the button created but the enabled property don't update when
> > the condition is fullfilled.
> >
> > Joćo Fernandes
> >
> > --- In flexcoders@yahoogroups.com, "Alistair McLeod"
<[EMAIL PROTECTED]> wrote:
> >
> >>Hi,
> >>
> >><mx:Button id="myButton"/>
> >>
> >>and
> >>
> >>Private function setButtonState() : Void
> >>{
> >> myButton.enabled = ( someval == otherval );
> >>}
> >>
> >>
> >>Its all in the docs....
> >>
> >>Ali
> >>
> >>--
> >>Alistair McLeod
> >>Development Director
> >>iteration::two
> >>[EMAIL PROTECTED]
> >>
> >>Office: +44 (0)131 338 6108
> >>
> >>This e-mail and any associated attachments transmitted with it may
> >
> > contain
> >
> >>confidential information and must not be copied, or disclosed, or
> >
> > used by
> >
> >>anyone other than the intended recipient(s). If you are not the
intended
> >>recipient(s) please destroy this e-mail, and any copies of it,
> >
> > immediately.
> >
> >>
> >>Please also note that while software systems have been used to try
> >
> > to ensure
> >
> >>that this e-mail has been swept for viruses, iteration::two do not
> >
> > accept
> >
> >>responsibility for any damage or loss caused in respect of any viruses
> >>transmitted by the e-mail. Please ensure your own checks are
carried out
> >>before any attachments are opened.
> >>
> >>
> >>-----Original Message-----
> >>From: flexcoders@yahoogroups.com
[mailto:flexcoders@yahoogroups.com] On
> >>Behalf Of joao_m_fernandes
> >>Sent: 19 April 2005 18:06
> >>To: flexcoders@yahoogroups.com
> >>Subject: [flexcoders] setting conditional "enabled" with AS
> >>
> >>
> >>
> >>Hi there,
> >>
> >>This may be a basic question.
> >>
> >>I know that if I use <mx:Button enabled="{someval == otherval}"/> My
> >
> > button
> >
> >>will be enabled whenever someval = otherval is true.
> >>
> >>How can I set this kind of conditional values to a button created with
> >>ActionScript ?
> >>
> >>Thanks,
> >>
> >>Joćo Fernandes
> >>
> >>
> >>
> >>
> >>
> >>
> >>Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.