views:

160

answers:

1

I have a flash app using the flex framework - I would like to bind a display object textField with data from my dataModel. How do I do this without the flex binding brackets "{ }"

Thanks in advance everyone.

A: 

The easiest way to do this is to use the BindingUtils class. For example, say you have an object foo with property bar that you want to bind to your text area's text property; all you need to do is the following in your ActionScript:

BindingUtils.bindProperty( myTextArea, "text", foo, "bar" );

This will tell Flex to watch foo for any changes to the property bar, and when changes occur, copy the value to myTextArea.text.

Full documentation can be found here.

Dan
Brilliant, but the mx.bindings package does not seem to be available for both my flex4 actionscript project or my flash as3. Which package have I not included into my application?
Glycerine
BindingUtils is located under the mx.binding.utils package and should be present in Flex 4.
Dan
My mistake I should have said, which flex lib swc? Currently I have, 'flex.swc', 'framework.swc', 'utilities.swc', 'flash-integration.swc'
Glycerine
It should be in framework.swc.
Dan
Thank you buddy - I should be able to work it out from here. Maybe I just need to app-path to it again and recompile.
Glycerine
No problem, glad I could help! :)
Dan