The following example shows how you can set left and right margins on a Spark TextArea control in Flex 4 by setting the paragraphStartIndent and paragraphEndIndent styles.
<?xml version="1.0" encoding="utf-8"?> <!-- http://blog.flexexamples.com/2009/06/04/setting-left-and-right-margins-on-a-spark-textarea-control-in-flex-4/ --> <s:Application name="Spark_TextArea_paragraphStartIndent_text" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <s:layout> <s:VerticalLayout /> </s:layout> <fx:Script> <![CDATA[ private function sliderStart_change(evt:Event):void { textArea.setStyle("paragraphStartIndent", sliderStart.value); } private function sliderEnd_change(evt:Event):void { textArea.setStyle("paragraphEndIndent", sliderEnd.value); } ]]> </fx:Script> <mx:ApplicationControlBar width="100%" cornerRadius="0"> <mx:Form styleName="plain"> <mx:FormItem label="paragraphStartIndent:"> <s:HSlider id="sliderStart" liveDragging="true" change="sliderStart_change(event);" /> </mx:FormItem> <mx:FormItem label="paragraphEndIndent:"> <s:HSlider id="sliderEnd" liveDragging="true" change="sliderEnd_change(event);" /> </mx:FormItem> </mx:Form> </mx:ApplicationControlBar> <s:Group width="100%" height="100%"> <s:TextArea id="textArea" textAlign="justify" left="10" right="10" top="10" bottom="10"> <s:content> <fx:String source="lorem.html" /> </s:content> </s:TextArea> </s:Group> </s:Application>
