' + text + ''; // var textFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT); // var textFlow:TextFlow = TextConverter.importToFlow(text, TextConverter.PLAIN_TEXT_FORMAT); // fastest possible impl var textFlow:TextFlow = new TextFlow(); textFlow.fontFamily = "Verdana"; textFlow.fontSize = 10; var p:ParagraphElement = new ParagraphElement(); var s:SpanElement = new SpanElement(); s.text = text; p.addChild(s); textFlow.addChild(p); textFlow.interactionManager = new EditManager(); var controller:ContainerController = new ContainerController(sprite); controller.setCompositionSize(200, 20); textFlow.flowComposer.addController(controller); textFlow.flowComposer.updateAllControllers(); return bg; } static private var format:TextLayoutFormat; public function buildInputManager(text:String):DisplayObject { var bg:Sprite = new Sprite(); // not till we have rectangles as compositionBounds input to DOCC var tm:TextContainerManager = new InputTestTextContainerManager(bg); tm.compositionWidth = 200; tm.compositionHeight = 20; if (format == null) { format = new TextLayoutFormat(); format.fontFamily = "Verdana"; format.fontSize = 10; } tm.hostFormat = format; tm.setText(text); tm.updateContainer(); return bg; } public function buildRectangles(text:String):DisplayObject { var bg:Sprite = new Sprite(); bg.graphics.beginFill(0xFFFFFF); bg.graphics.lineStyle(1, 0x000000); bg.graphics.drawRect(0,0,200,20); bg.graphics.endFill(); return bg; } // TextField Factory static private var defaultTextFormat:TextFormat; public function buildTextField(text:String):DisplayObject { if (!defaultTextFormat) { defaultTextFormat = new TextFormat(); defaultTextFormat.font = "Verdana"; defaultTextFormat.size = 10; } var a:TextField = new TextField(); a.type = "input" a.defaultTextFormat = defaultTextFormat; a.text = text; a.width = 200; a.height = 20; a.backgroundColor = 0xFFFFFF; a.background = true; a.border = true; a.borderColor = 0x000000; return a; } // count of number of tests run this session private var testCount:int = 0; private var queueResults:Boolean = false; /** generate a report at the next enter frame */ public function handleEnterFrame(): void { if (currIteration == -1) return; if (timingRendering) { totalRenderTime += getTimer() - beginThisRender; timingRendering = false; } // report results if appropriate if (currIteration < numberOfIterations) { Step(); // prepare for the next iteration currIteration++; // begin timing rendering timingRendering = true; beginThisRender = getTimer(); } else { try { new LocalConnection().connect('dummy'); new LocalConnection().connect('dummy'); } catch (e:*) {} queueResults = true; createTest.enabled = true; currIteration = -1; } if (queueResults) { reportResults(); queueResults = false; } } // Grid generator. private function createInputs():void { var curY:int = 10; var input:DisplayObject; for (var i:int = 0; i < 25; i++) { var st:String = sampleText; input = this[_func](st); lineHolder.rawChildren.addChild(input); input.x = 10; input.y = curY; input = this[_func](st); lineHolder.rawChildren.addChild(input); input.x = 220; input.y = curY; curY += input.height + 2; } } private function reportResults():void { var totalTestTime:int = totalRenderTime + totalCreationTime; flash.system.System.gc(); //mark flash.system.System.gc(); //sweep var memoryAllocated:Number = flash.system.System.totalMemory/1024; var vellumType:String = "Vellum Build: " + flashx.textLayout.TextLayoutVersion.BUILD_NUMBER + "\n"; resultText = new Text(); resultText.text = "CreationTime (msecs): " + totalCreationTime.toString() + "\nRenderTime (msec): " + totalRenderTime.toString() + "\nTotalTime (msec): " + totalTestTime.toString() + " \nmem (K): " + memoryAllocated.toString() + "\n" + vellumType; resultText.x = 80; resultText.y = 140; resultText.width = 400; resultText.setStyle("fontFamily", "Verdana"); resultText.setStyle("fontSize", 18); resultText.opaqueBackground = 0xFFFFFFFF; lineHolder.addChild(resultText); this.dispatchEvent(new Event(Event.COMPLETE)); } ]]>