on rereading your post i realise that what you are after is change events
(but my post will also help a bit me thinks)
a few people did custom annotations which function like an event listener,
just google a bit, i think it will make your life easier.
////old post///
ok, i will approach it slightly differently.
I would use a presentation model to bind the text to,

so
<component>
<control text="presModel.someText"/>
</component>
in my pres model

class presModel
{

[Bindable(localChange)]
[Bindable (someTextChange)]
public function get someText():String

[Bindable(localChange)]
[Bindable (someOtherTextChange)]
public function get someOtherText():String
}

this way you have groups of text that update at the same time when your
local changes (which in the workflow we use would look something like this
(still inside this presModel)
[Trigger (path="myModel.theLocalleValueIWantToKnowAbout")]
public function set localle(localle:String)
{
dispatchEvent("localChange")
}
where this localChange event will update all the strings which have a
bindable declared with that custom event name.

the trigger annotation is basically an event listener and is the same as
saying
in my local presentation model notify me when the applications localle
changes,
thus someAppModel.addEventListener("localChange....)

jpn
On Wed, Jan 28, 2009 at 12:09 AM, Thomas, Erik <erik_tho...@intuit.com>wrote:

>    Having just localized a medium sized application into Spanish, I ran
> into a recurring pattern I had to work around that I really shouldn't have
> to, specifically around data binding localized resources from ActionScript.
>
> For example, in MXML, one can data bind a localized resource and when the
> localeChain is switched dynamically, all bound clients will requery their
> values and the new language will display:
>
> <mx:Label text="{resourceManager.getString(ResourceEnums.COMMON,
> 'labelAppointments}"/>
>
> When the localeChain is switched, the label above will automatically update
> to the Spanish version, just like magic. This is a very cool feature of Flex
> 3 resource management.
>
> However, there are many use cases where I need to bind to resource
> bundles from within ActionScript, sort of like this:
>
> public class Foo
> {
>     [Bindable]
>     public var bar:String;
>
>     public function Foo()
>     {
>         bar = ResourceManager.getString(ResourceEnums.COMMON,
> 'labelAppointments');
>     }
> }
>
> When the localeChain is updated, "bar" is obviously not automatically
> updated because bar is not bound to the resource, it is just a simple
> assignment.
>
> BindingUtil.bindProperty and bindSetter don't appear to offer parameters
> that will work with ResourceManager. I've experimented a little, but it does
> not appear possible to use BindingUtils to bind to a resource.
>
> I had to work around this by listening for a localeChange event and then
> reassigning the resource to the variable. This does not scale.
>
> So my question is simple: *can you bind a variable to a resource in
> ActionScript? If so, how?*
>
> Thanks!
>
> Erik
>
> *Erik Thomas* | Small Business Group, *Intuit* | Staff Engineer
> | 650-944-2602
>
>  
>



-- 
j:pn
\\no comment

Reply via email to