Correction of a sample code in “Using the Text Layout Framework” of the CS5 help
“Using the Text Layout Framework” in “ActionScript 3.0 Developer’s Guide” on the Flash CS5 help includes some example codes to show how to use the Text Layout Framework. However, the second example in the section “The Text Layout Framework View” yields errors. The following two corrections should be made.
First, insert the xmlns attribute into the Flow element of the XML data (markup).
// var markup:XML = <TextFlow><p><span>Hello, World</span></p></TextFlow>;
var markup:XML = <TextFlow xmlns=’http://ns.adobe.com/textLayout/2008′><p><span>Hello, World</span></p></TextFlow>;
Second, the method updateAllContainers() is not implemented in the IFlowComposer interface. Use the updateAllControllers() method instead.
// myFlow.flowComposer.updateAllContainers();
myFlow.flowComposer.updateAllControllers();
The corrected frame action below works and shows the text in the top left corner of the stage.
// import necessary classes import flashx.textLayout.container.*; import flashx.textLayout.compose.*; import flashx.textLayout.elements.TextFlow; import flashx.textLayout.conversion.TextConverter; // first, create a TextFlow instance named myFlow // var markup:XML = <TextFlow><p><span>Hello, World</span></p></TextFlow>; var markup:XML = <TextFlow xmlns='http://ns.adobe.com/textLayout/2008'><p><span>Hello, World</span></p></TextFlow>; var myFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT); // second, create a controller // the first parameter, this, must point to a DisplayObjectContainer // the last two parameters set the initial size of the container in pixels var contr:ContainerController = new ContainerController(this, 600, 600); // third, associate it with the flowComposer property myFlow.flowComposer.addController(contr); // fourth, update the display list ; // myFlow.flowComposer.updateAllContainers(); myFlow.flowComposer.updateAllControllers();