Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Questions about bindable in Flex

Tags:

apache-flex

Since I found the webpages explaning the bindable propety quite confusing,so I would like to post my question here,which is quite simple,if I declare a variable to be bindable,does that mean whenever I changed the value of this variable in another class,all appearence of this variable will be synchronized to be the same value at the same time?

Say,if boolean variable "select" is declared to be bindable in Class A and default to be false,and we have an if statement in class A like if(select).

Then in another class,we changed the value of "select" to be true,will that if(select) statement pass the test ?

Also,how about the following setter method that is defined to be bindable:

[Bindable]
public function set isShowingAvg(b:Boolean):void
{
   _isShowingAvg = b;

   hasChanged();
}

Does this code imply that changing the value of _isShowingAvg is also going to be broadcasted?

Thanks in advance.

Thanks for your idea.

like image 663
Kevin Avatar asked May 04 '26 01:05

Kevin


1 Answers

Declaring a property as Bindable means that when you change the value, an event will get broadcasted. This event enables data binding, but it's not necessarily automatic.

If the consuming class is MXML and you use brackets, like this:

<mx:Button enabled="{selected}" />

Then the MXML compiler will generate the appropriate binding code and anytime selected changes, enabled will also get changed.

If you're using it outside MXML then you'll either subscribe to the event to detect changes or use BindingUtils.

like image 93
Samuel Neff Avatar answered May 07 '26 09:05

Samuel Neff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!