我正在制作简单的编辑器。我想要这样,当我写任何文本时,让我们将 RichEditableText 中的无色文本替换为彩色文本。
例如:PHP --><s:span color="#FF0000">PHP<s:span>
此代码不起作用:
editorum.text = editorum.text.replace('PHP','<s:span color="#FF0000">php<s:span>');
编辑部是:<s:RichEditableText id="editorum" ></s:RichEditableText>
源代码:
<?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"
width="319" height="198" minWidth="955" minHeight="600">
<fx:Style source="ops.css"/>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flashx.textLayout.formats.TextLayoutFormat;
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import spark.events.TextOperationEvent;
import spark.utils.TextFlowUtil;
protected function editorum_changeHandler(event:TextOperationEvent):void
{
editorum.text = editorum.text.replace('melon','<s:span color="#FF0000">melon<s:span>');
}
]]>
</fx:Script>
<s:RichEditableText id="editorum" x="10" y="28" width="299" height="159"
change="editorum_changeHandler(event)">
</s:RichEditableText>
<s:Label x="10" y="10" width="119" text="Write 'melon' :"/>
</s:Application>
另一个问题;最后如何发送指针?当我按任意键时,指针将要处理。试试:http ://samed.us/samples/ops3.swf
谢谢你的帮助...