Bindings are based on events.

When you write:

[Bindable]
public function get myProperty():String { ... }
public function set myProperty(value:String):void { ... }

The flex compiler will actually decorate this code, something like this:

[Bindable(event="propertyChange")]
public function get myProperty():String { ... }
public function set myProperty(value:String):void { ... ; dispatchEvent new
PropertyChangeEvent(...) }

At runtime, when bindings are estabilished, the framework will setup event
listeners for these declared events and will trigger the re-evaluation of
the binding expression when the binding event of each "bindable element" of
the expression is dispatched.

Now, when you use a read-only property, the compiler isn't able to
automatically provide the logic for the setter (since it is missing), and
usually the compiler will warn you that the binding expression may not be
observed.

In this case, you should manually declare the event related to the change
of that property value, and you have the responsibility to dispatch it each
time you change its value, i.e. when you know that the value returned by
that getter is changed if called again.






2014-06-26 14:03 GMT+02:00 Christofer Dutz <[email protected]>:

> Nope ... the other way around.
> last() is able to emit "lastChangedEvent" events ... it doesn't consume
> them.
>
> Chris
>
> ________________________________________
> Von: Kessler CTR Mark J <[email protected]>
> Gesendet: Donnerstag, 26. Juni 2014 11:58
> An: [email protected]
> Betreff: RE: Bindable functions
>
> //This responds to an event to show binding changes.
> [Bindable("lastChangedEvent")]
> public function get last():Boolean
> {
>     return this.viewIndex === (this.numElements - 1);
> }
>
>
> //This could dispatch the event to trigger the binding changes after a new
> element has been added.
> dispatchEvent(new Event("lastChangedEvent "));
>
>
>
> -Mark
>
> -----Original Message-----
> From: Scott Matheson [mailto:[email protected]]
> Sent: Wednesday, June 25, 2014 5:20 PM
> To: [email protected]
> Subject: Bindable functions
>
> Hi
>    well I have never manage to get Bindable functions to work, but now i
> may need then
>
> I have a view stack, with a renderer, in the rendered i would to disable
> elements of the render dependent on the view stack, i could hold a bit off
> Bindable data (thats what i do in other place), if i could create a
> Bindable function i could call this function in the render and disable
> elements as needed
>
> unfortunately i can not get this approach to work
>
>
>
> [Bindable]
>
> public function get last():Boolean
>
> {
>
> return this.viewIndex === (this.numElements - 1);
>
> }
>
>
>
> <common:ViewStack id="block" dataProvider="{blocks}"
>
>   verticalCenter="0" horizontalCenter="0"
>
>   itemRenderer="com.peach.uofs.lesson.ReadingBlockRenderer"
>
>   viewChange="setHLClip(event)">
>
> </common:ViewStack>
>
>
>
> i want to be able to dibble a button in ReadingBlockRenderer
>
>
> ________________________________
>
> Disclaimer: This electronic mail and any attachments are confidential and
> may be privileged. If you are not the intended recipient, please notify the
> sender immediately by replying to this email, and destroy all copies of
> this email and any attachments. Thank you.
>

Reply via email to