Hi,

Yes, even I've done that. But my main gripe is that when you have a Bindable
tag with your custom event name, is it not possible to use it directly with
any custom/built-in flex control?

[Bindable("myEvent")]
private var txt:String = "HI";

<mx:Text text="{txt}" /> // is this not possible if I use custom events?

I've always used plain bindable tags but I'd like to know whether I can
achieve the same auto-updation functionality when it comes to using bindable
tags with custom events.

Regards,
sasuke


Richard Rodseth wrote:
> 
> I've never looked at the implementation. When I do this, I create a custom
> getter and setter:
> 
> [Bindable("fooChanged")]
> public function get foo():Boolean {
>   return _foo;
> }
> 
> public function set foo(value:Boolean):void {
>   if (value != _foo) {
>     _foo = value;
>    dispatchEvent(new Event("fooChanged"))
> }
> }
> 
> Note that you can also have computed properties based on multiple
> properties:
> 
> [Bindable("fooChanged")]
> [Bindable("barChanged")]
> public function get foobar():Boolean {
>   return _foo && _bar;
> }
> 
> 
> 
> On Sat, May 1, 2010 at 12:54 PM, sasuke <[email protected]>
> wrote:
> 
>>
>>
>>
>> Hi folks,
>>
>> The Bindable metadata tag allows an optional event name to be specified
>> which would be event name that would be dispatched when the property in
>> consideration changes. I've read somewhere that specifying a distinct
>> event
>> name for each bindable property reduces the performance overhead (less
>> work
>> for BindingUtils or so it seems, I can't seem to find the actual
>> implementation detail). But this doesn't work with bindable properties
>> when
>> used with flex controls. For e.g. this *works*
>>
>> <mx:Script>
>> [Bindable]
>> private var txt:String = "HI";
>>
>> private function onCreationCompleteDone(event:Event):void
>> {
>> txt = "Changed text!";
>> }
>> </mx:Script>
>> <mx:Text text="{txt}" />
>>
>> This doesn't (notice the event name specified):
>>
>> <mx:Script>
>> [Bindable("myEvent")]
>> private var txt:String = "HI";
>>
>> private function onCreationCompleteDone(event:Event):void
>> {
>> txt = "Changed text!"; // Never called!
>> }
>> </mx:Script>
>> <mx:Text text="{txt}" />
>>
>> I did try analyzing the autogenerated AS files; the ones generated when I
>> use simple [Bindable] is pretty easy to understand since it generates
>> plain
>> getter and setter for the `txt` property but when I use
>> [Bindable("someEvent")], the code generated is a bit cryptic with the
>> stuff
>> with Watchers and all that.
>>
>> Would someone be kind enough to shed some light on this matter? How this
>> all
>> this Bindable stuff work under the hood?
>>
>> TIA,
>> sasuke
>> --
>> View this message in context:
>> http://old.nabble.com/Bindable-metadata-tag---event-name-tp28422913p28422913.html
>> Sent from the FlexCoders mailing list archive at Nabble.com.
>>
>>  
>>
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Bindable-metadata-tag---event-name-tp28422913p28424902.html
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to