私がやりたいことは、TLFTextField の書式設定プロパティを取得し、それを別の TLFTextField に適用することだけです。これは、従来の TextField を使用すると簡単でした。
var textFormat:TextFormat = text1.getTextFormat();
text2.setTextFormat(textFormat);
TLFTextField には getTextFormat と setTextFormat 関数がありますが、どちらも非常にバグがあります。getTextFormat は、selectable プロパティを true に変更した場合にのみ機能します。それ以外の場合は、null オブジェクト エラーが生成されます。setTextFormat オブジェクトの一部のプロパティが null でない場合、setTextFormat は NaN エラーを生成します。
TextLayoutFormat オブジェクトは、TLFTextFields の代わりに使用されることになっています。オブジェクトを設定するには、次のようにします。
var text1:TLFTextField = new TLFTextField();
var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
var textFlow:TextFlow = text1.textFlow;
textFlow.hostFormat = textLayoutFormat;
textFlow.flowComposer.updateAllControllers();
ただし、現在、text1 から TextLayoutFormat を「取得」する方法がわかりません。ある人は次のように提案しました。
textLayoutFormat = ((text1.textFlow.getChildAt(0) as ParagraphElement).getChildAt(0) as SpanElement).computedFormat as TextLayoutFormat;
しかし、これはnullを返しました。別の TLFTextField に適用できるように TextLayoutFormat を取得する方法を知っている人はいますか?