Skip to main content

Posts

Showing posts from July, 2009

SetStyle() Method Autoresizing Problem in Flex

setStyle() Method: Flex setStyle() method is used to change an object's style properties at runtime, for example in the script section you can write someObject.setStyle("fontSize", varSize); to change someObject’s font size to the size stored in the variable “varSize”. Resize Problem with setStyle(): The problem I faced using setStyle() was that I wanted a textAarea to resize its width after the textArea’s fontSize is increased. For example if the font size is set to too large which cannot be accommodated in the current width then the text will not fit in the textArea nor the textArea will resize itself if the vertical and horizontal Scrolling policy is set to “off”. The straight forward approach which should (but didn’t ) work is given below to achieve the resizing effect. public function setFontSize(): void { myTextArea.setStyle( "fontSize" ,varSize); myTextArea.validateProperties(); myTextArea.width = textareaScrolling.textWidth; } However the textArea’s w...

Custom ItemRenderer for Tree Control in Flex

In this post I am going to describe how you can modify the appearance of tree control. There are some examples already available on the internet but still I had to do some research and work to get this thing done. I am going to follow a Top-Down approach so you can follow along easily. Step-1 Making a Tree Control: We need an xml to provide it as a data provider to a tree control. A sample XML for the tree: <mx:xmllist id="treeData"> <node label="Root"> <node label="Parent-1"> <node label="Child-1"> <node label="Child-2"> <node label="Child-3"> <node label="Child-4"> </node> <node label="Parent-2"> </node> </mx:XMLList> MXML for the tree: <mx:tree id="myTree" labelfield="@label" labelfield="@label" showRoot="false" dataProvider="{treeData}" change="treeChanged(event)...