aodz

Flex “Bindable” tag

Posted by: vx on: May 21, 2009

the Bindable tag is widely used in flex and in simpleterms its used to bind an entity to other entity if there is a change in the source.
The tag can have the following form:

[Bindable]
public var foo;

The Flex compiler automatically generates an event named propertyChange for the property. If the property value remains the same on a write, Flex does not dispatch the event or update the property.

You can also specify the event name, as the following example shows:

[Bindable(event="fooChanged")]
public var foo;

In this case, you are responsible for generating and dispatching the event, typically as part of some other method of your class. You can specify a [Bindable] tag that includes the event specification if you want to name the event, even when you already specified the [Bindable] tag at the class level.

In order for binding to work you need to make sure changes to the data are known to the framework. Unlike most of dynamic languages implementations, ActionScript 3 is built for speed and heavily utilizes direct access to the properties and methods. In this situation the only way for data to notify the world about the changes is to embed the code to fire change events.

Flex compiler helps in a big way by introducing [Bindable] and [Managed] tags. If you prefix your variable with [Bindable] tag, compiler does the following:
1. Inspects every public property and setter of you variables class and generates wrapper getters/setters that adds event notification.
2. Every time “bindable” property is being used, compiler references these getters/setters instead of original properties

Tags: ,

Leave a Reply

I have moved to a different location

check out my new home
Flexout

calendar

May 2009
M T W T F S S
« Mar    
 123
45678910
11121314151617
18192021222324
25262728293031

Blog Stat

  • 39,096 Hop's so far!!!

follow me

Archives

Linkedin Blogger Twitter Youtube Orkut

latest flickr photos

shankh ceremony performed by priest

jal archana at ganga ghat

kneeling priest

aarti at varanasi dashasamedh ghat

the devi looking down towards us through the smoke

More Photos