检测文本何时进入TextFlow对象中ContainerController的结尾

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了检测文本何时进入TextFlow对象中ContainerController的结尾相关的知识,希望对你有一定的参考价值。

This snippet shows how you can detect when a FlowElement that has been added to a TextFlow object (Text Layout Framework) has run to the end of the container that is flowing into. You may have linked containers that you are flowing a load of lorem ipsum into for a mock up and you want the containers to be full of text. You will need to detect when the text has reached the end otherwise the flow will continue but not be visible.
  1. /*
  2. A good idea to set a config object to pass into the TextFlow object when you create it
  3. */
  4. config = Configuration(TextFlow.defaultConfiguration).clone();
  5.  
  6. /*
  7. And add this overflowPolicy to it as well as your formatting defaults
  8. */
  9. config.overflowPolicy = OverflowPolicy.FIT_DESCENDERS;
  10.  
  11. textFlow = new TextFlow(config);
  12.  
  13. /*
  14. Now imagine we are in a loop which adds a paragraph of lorem ipsum to the textflow and updates the controllers and checks if the flow is now out of the bounds of the container
  15. */
  16.  
  17. while(LOOP)
  18. {
  19. textFlow.addChild(myParagraphElement); // you've created the paragraph
  20. textFlow.flowComposer.updateAllControllers(); // you've created the controllers
  21.  
  22. var containerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(textFlow.textLength-1);
  23. if(containerIndex==-1) textFlowCompleteHandler();
  24. }

以上是关于检测文本何时进入TextFlow对象中ContainerController的结尾的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 检测文本何时在TextFlow对象中运行到ContainerController的末尾

ActionScript 3 检测文本何时在TextFlow对象中运行到ContainerController的末尾

JavaFX - 垂直居中TextFlow中的文本

ActionScript 3 从TextFlow中删除所有FlowElement对象

创建TextFlow配置对象

检测应用程序何时进入我的视图背景的最佳方法是啥?