<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="1024" minHeight="384" pageTitle="一个简单的文本编辑器">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.ColorPickerEvent;
import mx.events.ListEvent;
private var fonts:ArrayCollection=new ArrayCollection([
{text:"宋体",value:"宋体"},
{text:"英章楷书",value:"英章楷书"},
{text:"英章行书",value:"英章行书"},
{text:"幼圆",value:"幼圆"},
{text:"隶书",value:"隶书"},
{text:"楷体",value:"楷体_GB2312"}
]);
protected function changeColor_changeHandler(event:ColorPickerEvent):void
{
this.richtxt.setStyle("backgroundColor",this.changeColor.selectedColor);
}
protected function fontSet_changeHandler(event:ListEvent):void
{
this.richtxt.setStyle("fontFamily",this.fontSet.selectedLabel);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Panel x="2" y="3" width="100%" height="100%" title="文本编辑器">
<s:Group x="0" y="0" width="1012" height="319">
<s:RichEditableText id="richtxt" x="0" y="0" height="309" width="1012" fontSize="18" text="无可奈何花落去"/>
</s:Group>
<s:Group x="0" y="318" width="1012" height="45">
<mx:ColorPicker x="6" y="14" id="changeColor" change="changeColor_changeHandler(event)"/>
<mx:ComboBox dataProvider="{fonts}" labelField="text" editable="false" id="fontSet" x="62" y="15" change="fontSet_changeHandler(event)"></mx:ComboBox>
</s:Group>
</s:Panel>
</s:Application>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="1024" minHeight="384" pageTitle="一个简单的文本编辑器">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.ColorPickerEvent;
import mx.events.ListEvent;
private var fonts:ArrayCollection=new ArrayCollection([
{text:"宋体",value:"宋体"},
{text:"英章楷书",value:"英章楷书"},
{text:"英章行书",value:"英章行书"},
{text:"幼圆",value:"幼圆"},
{text:"隶书",value:"隶书"},
{text:"楷体",value:"楷体_GB2312"}
]);
protected function changeColor_changeHandler(event:ColorPickerEvent):void
{
this.richtxt.setStyle("backgroundColor",this.changeColor.selectedColor);
}
protected function fontSet_changeHandler(event:ListEvent):void
{
this.richtxt.setStyle("fontFamily",this.fontSet.selectedLabel);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Panel x="2" y="3" width="100%" height="100%" title="文本编辑器">
<s:Group x="0" y="0" width="1012" height="319">
<s:RichEditableText id="richtxt" x="0" y="0" height="309" width="1012" fontSize="18" text="无可奈何花落去"/>
</s:Group>
<s:Group x="0" y="318" width="1012" height="45">
<mx:ColorPicker x="6" y="14" id="changeColor" change="changeColor_changeHandler(event)"/>
<mx:ComboBox dataProvider="{fonts}" labelField="text" editable="false" id="fontSet" x="62" y="15" change="fontSet_changeHandler(event)"></mx:ComboBox>
</s:Group>
</s:Panel>
</s:Application>