検索結果のテキストで、検索されたキーワードを強調表示したい検索結果ページがあります。これにはTextLineを使用することが提案されましたが、それを機能させる方法を理解するのに苦労しています。私はシンプルでコンパイル可能なダミーアプリケーションを開始し、誰かが続行する方法についていくつかのヒントを教えてくれることを望んでいました。
<?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"
initialize="initApp();">
<fx:Script>
import flash.display.Sprite;
import flash.text.engine.*;
private var textLine:TextLine;
private function initApp():void {
var normalFormat:ElementFormat = new ElementFormat(null, 12, 0x000000);
var highlightFormat:ElementFormat = new ElementFormat(null, 14, 0xff0000);
var textBlock:TextBlock = new TextBlock(new TextElement("This is text that has KEYWORDS. I would like to highlight these KEYWORDS by changing their font color and adding a light yellow background graphic.", normalFormat));
textLine = textBlock.createTextLine();
textLine.y = 100;
embeddedFontHolder.addChild(textLine);
}
</fx:Script>
<mx:UIComponent width="100%" id="embeddedFontHolder" />
</s:Application>
誰かアイデアはありますか?
乾杯、バズ