Flex Gumbo中如何格式化显示TextArea选中的文本的例子
By Minidxer | September 9, 2009
接下来的例子演示了Flex Gumbo中如何通过调用setSelectionFormat()函数,格式化显示TextArea选中的文本。
下面是完整代码(或点击这里察看):
下面是main.mxml:
- <?xml version="1.0" encoding="utf-8"?>
- <s:Application name="Spark_TextArea_setSelectionFormat_test"
- xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/halo">
- <fx:Script>
- <![CDATA[
- import flash.text.engine.FontWeight;
- import flashx.textLayout.formats.TextLayoutFormat;
- private function btn_click(evt:MouseEvent):void {
- var styleObj:TextLayoutFormat = new TextLayoutFormat();
- styleObj.fontWeight = FontWeight.BOLD;
- styleObj.color = 0xFF0000; // red
- textArea.setFormatOfRange(styleObj);
- }
- ]]>
- </fx:Script>
- <mx:ApplicationControlBar width="100%" cornerRadius="0">
- <s:Button id="btn"
- label="Style selected text"
- click="btn_click(event);" />
- </mx:ApplicationControlBar>
- <s:TextArea id="textArea"
- horizontalCenter="0"
- verticalCenter="0">
- <s:content>
- <s:p>Select some text and click the button to apply a bold/red style.</s:p>
- </s:content>
- </s:TextArea>
- </s:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
Gumbo, TextArea |
No Comments » |
Tags: Gumbo, setFormatOfRange()