Sharp Mind

one more blog for people who like to work in flex

Flex Tip of the Day #5: Bindable property

If you use  [Bindable] property then do not forget to put semicolon at the
end of  all the declaration before the [Bindable] property, otherwise
compiler will throw error .
I have given three different scenarios below.

Code 1: Compliler will throw error for missing semicolon

<?xml version=”1.0″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml“>
<mx:Script>
 <![CDATA[
        private var myNum:Number= 4
        [Bindable]
        private var myStr:String = “HelloWord!!”
    ]]>
</mx:Script>
<mx:Button id=”button1″ label=”{myStr}” width=”100″/>
</mx:Application>

Code 2: Complier will not throw any  error for missing semicolon.

<?xml version=”1.0″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml“>
<mx:Script> 
    <![CDATA[
        [Bindable]
        private var myStr:String = “HelloWord!!”;
        private var myNum:Number= 4
    ]]>
</mx:Script>
<mx:Button id=”button1″ label=”{myStr}” width=”100″/>
</mx:Application>

Code 3: This is the correct one. I have put semicolon*

<?xml version=”1.0″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml“>
<mx:Script>
   <![CDATA[
        private var myNum:Number= 4;
        [Bindable]
        private var myStr:String = “HelloWord!!” ;
   ]]>
</mx:Script>
<mx:Button id=”button1″ label=”{myStr}” width=”100″/>
</mx:Application>

June 30, 2007 - Posted by Kanu Wadhwa | Flex Tips | | 1 Comment

1 Comment »

  1. thanks

    Comment by paylasim | October 11, 2008 | Reply


Leave a comment