간단한 편집기를 만들고 있습니다. 필자는 텍스트를 쓸 때 RichEditableText의 색상 텍스트에 무색 텍스트를 대체하여 쓰도록하겠습니다.Flex Spark 텍스트를 색상 텍스트로 바꿉니다.
예를 들어: PHP -><s:span color="#FF0000">PHP<s:span>
이 코드는 작동하지 :
editorum.text = editorum.text.replace('PHP','<s:span color="#FF0000">php<s:span>');
Editorum은 다음과 같습니다 <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
감사합니다 ... 대신이 라인의
나는 당신이하려고하는 것이 분명하지 않습니다. 이것은 PHP 질문입니까 아니면 플렉스 질문입니까? 특히이 라인은 "필자는 PHP를 작성할 때 RichEditableText의 색상 텍스트에 무색 텍스트를 대체하여 쓰도록하겠습니다." 특히 혼란 스럽습니다. 또한 작동하지 않는 코드 세그먼트를 언급합니다. '작동하지 않습니다.'를 확장하십시오. 컴파일 시간 오류가 발생합니까? 런타임 오류? 또는 다른 것? – JeffryHouser
영어로 유감입니다. 좋지 않아. 유연한 질문입니다. PHP는 샘플 텍스트입니다. PHP는 절대로 사용하지 마십시오. 당신은 어떤 텍스트라도 생각합니다. exampe '멜론'들어. RichEditableText에 멜론을 쓸 때, 함수는 컬러 텍스트를 '멜론'으로 변경합니다. – SamedDeger
질문을 수정했습니다. – SamedDeger