0
我正在嘗試使用TextLayoutFramework來嘗試使用選項卡。基於一些例子,這應該工作,但不...Flex SDK:如何使用TextLayoutFramework將選項卡分配給Spark RichtText
任何想法爲什麼txt顯示如下,空格而不是linebreaks或製表符?
111111 222222 33333 44444 55555 66666 77777
這是所使用的代碼:
<fx:Script>
<![CDATA[
import flash.text.engine.TabAlignment;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.formats.TabStopFormat;
import flashx.textLayout.formats.TextLayoutFormat;
private function setText() : void
{
// Test content
var txt : String = "<p><span>111111\n222222\t33333\t44444\t55555\n66666\t77777</span></p>";
var xml : XML = new XML("<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>" + txt + "</TextFlow>");
// Define three tab positions
var tabStop1:TabStopFormat = new TabStopFormat();
tabStop1.alignment = TabAlignment.START;
tabStop1.position = 50;
var tabStop2:TabStopFormat = new TabStopFormat();
tabStop2.alignment = TabAlignment.CENTER;
tabStop2.position = 150;
var tabStop3:TabStopFormat = new TabStopFormat();
tabStop3.alignment = TabAlignment.END;
tabStop3.position = 250;
// Define the formatter
var format:TextLayoutFormat = new TextLayoutFormat();
format.tabStops = new Array(tabStop1, tabStop2, tabStop3);
// Put the text in the textbox
txtBox.textFlow = TextConverter.importToFlow(xml, TextConverter.TEXT_LAYOUT_FORMAT);
// Assign the formatter to the textbox
txtBox.textFlow.format = format;
}
]]>
</fx:Script>
<s:RichText id="txtBox" top="25" left="25" width="400" height="200" />