سؤال

i have a big problem to bind this method:

[Bindable(event=LOCALE_CHANGED_EVENT_TYPE)]
public static function localeString(pathInLocale:String):String
{
    var value:String=LocaleUtil.getValueFromLocaleFromStringPath(pathInLocale);
    if (value == null || value.length == 0)
    {
        value=pathInLocale;
    }
    trace(value);
    return value;
}

like this:

<mx:DataGridColumn headerText="{PDMPlusPlusModelLocator.localeString('employeeView.employeeFilter.noDottedManager')}" />

The Binding seams simply not beeing executed. (Think that, because the trace() is not called and i have debuged it)

But the same works perfect here:

<mx:Label text="{PDMPlusPlusModelLocator.localeString('employeeView.employeeFilter.noDottedManager')}"/>

Dose anyone have an idea what the Problem is?

Note: i reade this post and i think it's the same problem, but it do not work for me cause of any reasons:

هل كانت مفيدة؟

المحلول

The problem lies here: [Bindable(event=LOCALE_CHANGED_EVENT_TYPE)]

This is a preprocessor rule that hasn't done a resolve on its references yet. Effectively what the [Bindable] does is to write an event listener for you (via a ChangeWatcher elsewhere), and since they are based on 'magic strings', you're statement would need to look similar to:

public static const LOCALE_CHANGED_EVENT:String = "localeChangedEvent";

[Bindable(event="localeChangedEvent")]
function foo(param:int):void
{
  var oldValue:int = _fooFighters;
  _fooFighters = param;
  if (oldValue != param) dispatch(new Event(LOCALE_CHANGED_EVENT));
}

Now this is over-simplified, but you can hopefully get the idea. As for why it works in the same mxml as the DataGrid, I can only speculate that your dispatched event isn't a defined Event Class but something similar above - just a defined string? Hard to say.

نصائح أخرى

Finally i found out what happens (and understand what Mike was meaning)

The problem is first:

This can not be used:

[Bindable(event=LOCALE_CHANGED_EVENT_TYPE)]

It should be:

[Bindable(event="foo.bar.LocaleChanged")]

And the secound fail:

the method should not be static, because it dose only worked once at startuptime if it is static.

Thx for you answers :)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top