这是不可能的,因为文本字段不支持强标签。从 textarea htmltext 中删除了强标记。但是您可以使用正则表达式。将最后一行拆分为单词并创建模式。往下看(也许你自己修改代码):
<?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"
creationComplete="application_creationCompleteHandler(event)"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected var str:String = "";
protected function application_creationCompleteHandler(event:FlexEvent):void
{
str = 'ActionScript 3 (AS3) is the open source object oriented programming (OOP) language of the Adobe <strong>Flash</strong> and <b>AIR</b> Platforms.';
textarea.addEventListener("htmlTextChanged", textarea_changeHandler, false, 0, true);
textarea.htmlText = str;
}
protected function textarea_changeHandler(event:Event):void
{
var allLines:Number = textarea.mx_internal::getTextField().numLines;
var line:String = textarea.mx_internal::getTextField().getLineText(allLines-1);
var arr:Array = line.match(/\w+[.!?]?/gi);
var pattern:String = "";
var i:uint = 0;
var l:uint = arr.length;
for ( ; i<l; i++)
{
pattern += "(<[^</]+?>)?\\s*" + arr[i] + "\\s*(<[^<]+?>)?" + "\\s*";
}
var regex:RegExp = new RegExp(pattern, "gi");
trace( str.match(regex) );
}
]]>
</fx:Script>
<mx:TextArea id="textarea" width="280" height="100" x="100"/>
</s:Application>