{testDataText}

; var tf:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT); var rslt:Sprite = new Sprite(); tf.flowComposer.addController(new ContainerController(rslt,compositionWidth,this.height-controlBox.height)); tf.flowComposer.updateAllControllers(); return rslt; } /** use the vellum factory via the callback. Test code for VJ */ private var containerFormat:TextLayoutFormat; public function buildVellumFactoryVJ(compositionWidth:Number):DisplayObject { if (!containerFormat) { containerFormat = new TextLayoutFormat(); containerFormat.verticalAlign = VerticalAlign.JUSTIFY; } var compositionHeight:Number = 500; _rslt = new Sprite(); _rslt.graphics.beginFill(0xff0000); // red _rslt.graphics.drawRect(0,0,compositionWidth,compositionHeight); _rslt.graphics.endFill(); factory.text = testDataText; factory.compositionBounds = new Rectangle(0,0,compositionWidth,compositionHeight); factory.textFlowFormat = containerFormat; factory.createTextLines(callback); return _rslt; } /** use the vellum factory via the callback. Test code for Explicit linebreaks */ private var explicitContainerFormat:TextLayoutFormat; public function buildVellumFactoryExplicit(compositionWidth:Number):DisplayObject { if (!containerFormat) { explicitContainerFormat = new TextLayoutFormat(); explicitContainerFormat.lineBreak = LineBreak.EXPLICIT; } var compositionHeight:Number = 500; _rslt = new Sprite(); _rslt.graphics.beginFill(0xff0000); // red _rslt.graphics.drawRect(0,0,compositionWidth,compositionHeight); _rslt.graphics.endFill(); factory.text = testDataText; factory.compositionBounds = new Rectangle(0,0,compositionWidth,compositionHeight); factory.textFlowFormat = explicitContainerFormat; factory.createTextLines(callback); return _rslt; } /** build rectangles */ public function buildRectangles(compositionWidth:Number):DisplayObject { var s:Shape = new Shape(); s.graphics.beginFill(0xff0000); // red s.graphics.drawRect(0,0,compositionWidth,this.height-controlBox.height); s.graphics.endFill(); return s; } /** build a TextField */ static private var defaultTextFormat:TextFormat; public function buildTextFieldExample(compositionWidth:Number):DisplayObject { if (!defaultTextFormat) { defaultTextFormat = new TextFormat(); defaultTextFormat.font = "Times New Roman"; } var a:TextField = new TextField(); a.defaultTextFormat = defaultTextFormat; a.text = testDataText; a.x = -2; a.y = -6; a.width = compositionWidth; a.height = 10000; a.multiline = true; a.wordWrap = true; return a; } /** test that builds nothing - used to measure the overhead of the harness */ public function buildNothing(compositionWidth:Number):DisplayObject { return null; } // debugging code private function displayHierarchy(root:DisplayObject):String { var outputString:String; outputString = flash.utils.getQualifiedClassName(root); outputString += " rect (" + root.x.toString() + "," + root.y.toString() + "," + root.width.toString() + "," + root.height.toString() + ")"; if (root is DisplayObjectContainer && (root as DisplayObjectContainer).numChildren > 0) { outputString += " {\n"; for (var i:int = 0; i < (root as DisplayObjectContainer).numChildren; i++) outputString += displayHierarchy((root as DisplayObjectContainer).getChildAt(i)); outputString += "}\n"; } return outputString; } // count of number of tests run this session private var testCount:int = 0; /** generate a report at the next enter frame */ public function handleEnterFrame(e:Event): void { if (stopAtNextFrame == 0) { stopAtNextFrame = 1; lineHolder.visible = true; beginRenderTime = getTimer(); } else if (stopAtNextFrame == 1) { var endRenderTime:int = getTimer(); creationTimeElapsed = endCreationTime - beginCreationTime; renderTimeElapsed = endRenderTime - beginRenderTime; var totalTimeElapsed:int = endRenderTime - beginCreationTime; testCount++; flash.system.System.gc(); //mark flash.system.System.gc(); //sweep var memoryAllocated:Number = flash.system.System.totalMemory/1024; trace(_func,"creation time (msecs)",creationTimeElapsed.toString(), "render time (msecs)",renderTimeElapsed.toString(), "total time (msecs)",totalTimeElapsed.toString(), " mem (K)", memoryAllocated); stopAtNextFrame = -1; var testDescription:String = testCount.toString() + ") iters: " + numberOfIterations.toString(); var playerType:String = this.debugMode ? "DEBUGGING PLAYER (not suitable for measuring performance)" : "RELEASE PLAYER "+Capabilities.version; var vellumType:String = "Vellum build: " + flashx.textLayout.TextLayoutVersion.BUILD_NUMBER + "\n" + (Configuration.tlf_internal::debugCodeEnabled ? "DEBUG vellum engine (not suitable for measuring performance)" : "RELEASE vellum engine"); resultText = new Text(); resultText.text = _func + "\n" + testDescription + "\nCreationTime (msecs): " + creationTimeElapsed.toString() + "\nRenderTime (msec): " + renderTimeElapsed.toString() + "\nTotalTime (msec): " + totalTimeElapsed.toString() + " \nmem (K): " + memoryAllocated.toString() + "\n" + playerType + "\n" + vellumType; resultText.x = 100; resultText.y = 140; resultText.width = 400; resultText.setStyle("fontFamily", "Minion Pro"); resultText.setStyle("fontSize", 24); resultText.opaqueBackground = 0xFFFFFFFF; lineHolder.addChild(resultText); this.dispatchEvent(new Event(Event.COMPLETE)); runButton.enabled = true; // start another test? removeEventListener(Event.ENTER_FRAME,handleEnterFrame); } } ]]>