Flex的RichTextEditor控件中如何利用textAreaStyleName和letter

转自http://blog.minidx.com/2008/04/23/762.html

主程序:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white" viewSourceURL="srcview/index.html">

    <mx:Style>
        .myTextAreaStyleName {
            fontFamily: Courier;
            letterSpacing: 3; /* pixels */
        }
    </mx:Style>

    <mx:Script>
        <![CDATA[
            import mx.events.SliderEvent;

            private function slider_change(evt:SliderEvent):void {
                var cssStyle:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".myTextAreaStyleName");
                cssStyle.setStyle("letterSpacing", evt.value);
            }
        ]]>
    </mx:Script>

    <mx:String id="str" source="lorem.txt" />

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="letterSpacing:">
                <mx:HSlider id="slider"
                        minimum="0"
                        maximum="20"
                        value="3"
                        liveDragging="true"
                        snapInterval="1"
                        tickInterval="1"
                        change="slider_change(event);" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:RichTextEditor id="richTextEditor"
            text="{str}"
            textAreaStyleName="myTextAreaStyleName"
            width="100%"
            height="100%" />

</mx:Application>


好东西啊~~~



后续:
但该代码有一个问题,就是字符间距的设置必须在所有样式设置(如颜色,对齐方式等)之前,否则它将撤消掉所有之前的设置~~~~这点让我很郁闷~~~看了很久的源代码可还是不晓得要怎样才好~~~唉~~水平有待提高啊~~~

你可能感兴趣的:(html,xml,Blog,Flex)