Revision: 25965
Updated Code
at April 15, 2010 03:23 by LeeProbert
Updated Code
/* A good idea to set a config object to pass into the TextFlow object when you create it */ config = Configuration(TextFlow.defaultConfiguration).clone(); /* And add this overflowPolicy to it as well as your formatting defaults */ config.overflowPolicy = OverflowPolicy.FIT_DESCENDERS; textFlow = new TextFlow(config); /* Create your containers from sprites and make sure the scrollPolicy is OFF */ var controller:ContainerController = new ContainerController(containerSprite,width,height); controller.verticalScrollPolicy = controller.horizontalScrollPolicy = ScrollPolicy.OFF; textFlow.flowComposer.addController(controller); /* 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 */ while(LOOP) { textFlow.addChild(myParagraphElement); // you've created the paragraph textFlow.flowComposer.updateAllControllers(); // you've created the controllers var containerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(textFlow.textLength-1); if(containerIndex==-1) textFlowCompleteHandler(); }
Revision: 25964
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 15, 2010 03:18 by LeeProbert
Initial Code
/* A good idea to set a config object to pass into the TextFlow object when you create it */ config = Configuration(TextFlow.defaultConfiguration).clone(); /* And add this overflowPolicy to it as well as your formatting defaults */ config.overflowPolicy = OverflowPolicy.FIT_DESCENDERS; textFlow = new TextFlow(config); /* 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 */ while(LOOP) { textFlow.addChild(myParagraphElement); // you've created the paragraph textFlow.flowComposer.updateAllControllers(); // you've created the controllers var containerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(textFlow.textLength-1); if(containerIndex==-1) textFlowCompleteHandler(); }
Initial URL
Initial Description
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.
Initial Title
Detecting when text has run into the end of the ContainerController in a TextFlow object
Initial Tags
text, layout
Initial Language
ActionScript 3