I did a little Googling for you:

http://twopointoh.vox.com/library/post/boolean-operations-in-mxml.html

Depending on what you are building, the Presentation Model pattern may be
overkill, but it's worth knowing about.

On Tue, Apr 13, 2010 at 12:28 AM, Doug <doug_pie...@ymail.com> wrote:

>
>
>
>
> Awesome stuff guys!!
>
> The &amp; thing didn't work for me when I tried that... I thought just
> maybe, but nah. This was part of the source of my question, "How do you do a
> logical AND?"
>
> The function method that Richard posted is something I am going to try as I
> think that's exactly what I'm looking for. I would like to avoid setting up
> an event listener, but if that's the only way...
>
> Thanks again for the help thus far... if anybody has anything else, please
> let me know!
>
>
> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, Richard
> Rodseth <rrods...@...> wrote:
> >
> > Rick is correct. You can also use a local binding function like this:
> >
> > <s:Button enabled="{enableButton(showMe, hideMe)}"/>
> >
> > where enableButton is a function in your Script block that takes two
> boolean
> > parameters.
> >
> > Or, if you have a presentation model, it could have a computed property
> > buttonEnabled
> >
> > <s:Button enabled="{model.buttonEnabled}"/>
> >
> > Excerpt of presentation model:
> >
> > [Bindable(event="showMeChanged")]
> > [Bindable(event="hideMeChanged")]
> > public function get buttonEnabled():Boolean {
> > return showMe && hideMe;
> > }
> >
> > public function set showMe(value:Boolean):void {
> > if (value != this.showMe) {
> > this.showMe = value;
> > dispatchEvent(new Event("showMeChanged"));
> > }
> > }
> >
> > Hope this helps.
> >
> >
> > On Mon, Apr 12, 2010 at 4:31 PM, Rick Genter <rick.gen...@...> wrote:
> >
> > >
> > >
> > >
> > > On Apr 12, 2010, at 10:31 AM, Doug wrote:
> > >
> > > > I seem to have little success with this and would like to know other
> ways
> > > of accomplishing what I want to do.
> > > >
> > > > I'm trying to enable/disable a button based on two pieces of
> criteria. It
> > > would seem that a logical OR or a logical AND would bridge these much
> like
> > > an IF statement, however, I'm struggling to make it work 100%.
> > > >
> > > > Consider a button:
> > > >
> > > > <s:Button enabled="{showMe || hideMe}"/>
> > > >
> > > > This button's enabled property is based upon the binding of the
> variables
> > > for "showMe" and "hideMe". If showMe or hideMe is true then the button
> is
> > > enabled. This works fine when using a logical OR. However, the
> following -
> > > using a logical AND - does not:
> > > >
> > > > <s:Button enabled="{showMe && hideMe}"/>
> > > >
> > > > How do you do a logical AND?? Also, if I wanted to set showMe and
> hideMe
> > > based on several lines of code how would I best do it? How would you
> bind a
> > > function output to a display object? I only see a way to do it based
> upon
> > > event:
> > > >
> > > > [Bind (event: <some event here>]
> > > > private function myFunction():void{}
> > > >
> > > > Thanks in advance!!
> > >
> > > I haven't tried this, but I suspect that you are being bitten by XML.
> Try
> > > this:
> > >
> > > <s:Button enabled="{showMe &amp;&amp; hideMe}"/>
> > >
> > > --
> > > Rick Genter
> > > rick.gen...@... <rick.genter%40gmail.com>
> > >
> > >
> > >
> >
>
>  
>

Reply via email to