Amy-28 wrote:
> 
> --- In flexcoders@yahoogroups.com, Mark Carter <[EMAIL PROTECTED]> wrote:
>> Doesn't that only work if you have a set isAllowed() as well?
> 
> No.  There is intentionally no setter function for isAllowed for the 
> reason you outline below:
> 

Ah, yes, sorry, my mistake. I didn't read that properly - I thought you just
placed a [Bindable] metatag on a getter function - in which case you would
need a setter function as well. However, now I see you use a
[Bindable(event="")] metatag - which is entirely different.


Amy-28 wrote:
> 
> You might find this presentation informative
> 
> http://link.brightcove.com/services/player/bcpid1733261879?
> bclid=1729365228&bctid=1741212660
> 

Thanks very much - thats a really useful presentation.

The general solution you propose, unfortunately, does not work in my
situation - which is rather more complex than the simplified representation
I originally posted.

I have an API with "isAllowed()" and I don't want to change this API - which
rules out using the [Bindable(event="")] metatag on that method. I also
don't want to listen on changes to various bindable vars which may or may
not be used in the calculation of isAllowed(). The caller of isAllowed()
should not make specific assumptions about how that calculation is made.
Kind of breaks encapsulation.

However, what I do know is calling any method on the same class as that
having isAllowed() MAY change the result of isAllowed().

I guess the best approach in this scenario is something like:

model.someFunctionThatMayChangeSomething();
updateEnabledAttributesInDataProvider();

...

model.otherFunctionThatMayChangeSomething();
updateEnabledAttributesInDataProvider();


function updateEnabledAttributesInDataProvider():void {
    for each (var menuitem:XML in menuitemsXML..menuitem) {
        var id:String = [EMAIL PROTECTED];
        var allowFuncName:String = "allow" + id.substring(0,
1).toUpperCase() + id.substring(1);
        if (model.hasOwnProperty(allowFuncName)) {
            [EMAIL PROTECTED] = model.this[allowFuncName]();
        }
    } 
}

So, not use databinding at all - instead, as Tracy suggested - update the
enabled attributes directly.

Sorry, this topic has changed course to something more like: "Automatically
enabling/disabling menuitems without using databinding"...
-- 
View this message in context: 
http://www.nabble.com/Best-practice-for-databinding-with-MenuBar--tp20622610p20654467.html
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to