As far as i understand,
The basic difference is, the property (source) which is bindable
(which can generate properychange event) can use any of the below
methods to update the destination property.
1. {} binding in mxml -> compile time binding
2. <mx:Binding> in mxml -> compile time binding
3.Bindingutils in Action script -> run-time binding
If the property is not bindable should use [Bindable] metadata to make
it bindable (so that it can generate propertyChange event by default).
Ex:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical">
<mx:Script>
<![CDATA[
import mx.binding.utils.ChangeWatcher;
[Bindable]
public var lbl_txt:String = "H";
private function onclick(event:MouseEvent):void
{
lbl_txt = "Hello";
}
]]>
</mx:Script>
<mx:Label id="lbl" text="{lbl_txt}"/>
<mx:Button label="click" click="onclick(event)" />
</mx:Application>
If you comment [Bindable], lbl (text property, destination) will not
be updated.
the [Bindable] metadata uses run-time binding, hence in optimization
(if use) you have to use –keep-as3-metadata switch.
On Nov 26, 10:57 pm, ravi kanth <[email protected]> wrote:
> Hi,
>
> I checked the below example,
>
> In the RtExt.as file, we are binding the variable 'name' using [bindable]
> tag.
>
> And in the mxml,
> we are importing the RtExt class and creating a variable of the class. So
> the above bindable variable 'name' can access directly in the mxml. If i
> wrong, please correct me.
>
> I removed the bindable tag in RtExt.as for variable 'name', it is working
> fine as it is earlier.
>
> So what is the difference?
>
> Thank,
> Ravi
>
> On Thu, Nov 26, 2009 at 11:42 AM, flexorz group of flex corders <
>
>
>
> [email protected]> wrote:
> > hi ravi ,
>
> > so in order keep the binding solid we can use the [Bindable] tag ,
> > what it really does is letting the component know ,hey i have changed
> > ..please act accordingly .
> > (by triggering an event , which you might already know.)
> > if not try this link to know more about [Bindable] tag.
> >http://livedocs.adobe.com/flex/3/html/help.html?content=databinding_8...
>
> > now ,
> > Suppose you want to use your own customClass where some of the properties
> > are bind-able in to other components which you use else where in the product
> > .
> > in such cases
>
> > you can use
> > bindingUtils or mxml version of it (binding tag).
>
> > note,
> > there are some cases where you dont want to use explicit binding using
> > bindingUtils and tag.
> > but when the change is not reflected , im sure those will come handy :-)
>
> > check the example how i bind the variable to extenal reference.code is self
> > explanery so let me know if you dont understand anything ok
>
> > *This is my external class*
>
> > package com
> > {
>
> > // if you want you can try [Bindable] tag for the class it self :)
> > public class RtExt
> > {
> > [Bindable] public var name:String;
>
> > public function RtExt()
> > {
> > name ="Socerties";
> > }
>
> > }
> > }
>
> > *this is my mxml*
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> > verticalAlign="middle" creationComplete="init()">
>
> > <mx:Script>
> > <![CDATA[
> > import com.RtExt;
> > import mx.binding.utils.BindingUtils;
>
> > [Bindable] private var myCustomClass:RtExt = new RtExt();
>
> > private function init():void
> > {
> > BindingUtils.bindProperty(NameText, "text", myCustomClass,
> > "name");
> > } // init
>
> > private function changeDogName():void
> > {
> > myCustomClass.name = NameInput.text;
> > } // changeName
> > ]]>
> > </mx:Script>
> > <mx:Binding source="myCustomClass.name" destination="NameText2.text"/>
> > <mx:Text id="NameText" text="{myCustomClass.name}" fontSize="12" />
> > <mx:Text id="NameText2" text="{myCustomClass.name}" fontSize="12" />
> > <mx:Spacer height="50" />
> > <mx:HBox>
> > <mx:Label text="Change name to: " />
> > <mx:TextInput id="NameInput" />
> > </mx:HBox>
> > <mx:Button label="change name" click="changeDogName()"/>
>
> > </mx:Application>
>
> > here im creating two binding methods on using utils and tag where you can
> > play around with.
>
> > try commenting
>
> > <mx:Binding source="myCustomClass.name" destination="NameText2.text"/>
> > or bindingUtils
>
> > or both.
>
> > try removing [Bindable] tag in places and observe the changes .
>
> > im sure you will be able to over come any doubts you have.
>
> > Best regards
>
> > Dinukx
>
> > On Thu, Nov 26, 2009 at 12:52 AM, Ravi <[email protected]> wrote:
>
> >> Hi All,
>
> >> I have doubt.
>
> >> for data biniding , we have 3 options,
>
> >> 1. {} binding in mxml
> >> 2. <mx:Binding> in mxml
> >> 3.Bindingutils in Action script.
>
> >> And what is the use of [bindable] meta tag? Any features add into
> >> this?
>
> >> Thanks,
> >> Ravi
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups
> >> "Flex India Community" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected]<flex_india%2bunsubscr...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/flex_india?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Flex India Community" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<flex_india%2bunsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/flex_india?hl=en.- Hide quoted text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.