我正在构建 RichText 控件的内容:
private function buildLabelTextElements():void
{
beforeResult=new SpanElement();
beforeResult.color=0x000000;
beforeResult.fontWeight=FontWeight.NORMAL;
searchResult=new SpanElement();
searchResult.color=0x9C0836;
searchResult.fontWeight=FontWeight.BOLD;
afterResult=new SpanElement();
afterResult.color=0x000000;
afterResult.fontWeight=FontWeight.NORMAL;
var paragraphElement:ParagraphElement=new ParagraphElement();
paragraphElement.addChild(beforeResult);
paragraphElement.addChild(searchResult);
paragraphElement.addChild(afterResult);
var textFlow:TextFlow=labelField.textFlow;
textFlow.addChild(paragraphElement);
/*var controller:ContainerController=new ContainerController(
labelField);
textFlow.flowComposer.addController(controller);*/
textFlow.flowComposer.updateAllControllers();
//labelField.textFlow=textFlow;
}
然后在另一个函数中,我正在更改 , 和 中的文本beforeResult
,searchResult
但afterResult
由于某种原因,我在控件中获取的文本是空的!我错过了什么?如果它可以帮助找到问题,我可以添加更改文本的代码,但基本上它只是beforeResult.text=...
然后labelField.textFlow.flowComposer.updateAllControllers();
谢谢你的帮助。