How to apply text formatting immediately?
Hello!
I apply text formatting to the empty newly created text flow. It seems to be strange that the formatting is not applied immediately, but when I start editing.
The small sample demonstrates the problem.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="
vertical"
creationComplete="onCreationComplete()"
>
<mx:Script>
<![CDATA[
import flashx.textLayout.events.FlowOperationEvent;
import flashx.textLayout.formats.ITextLayoutFormat;
import flash.text.engine.RenderingMode;
import flash.text.engine.FontLookup;
import flashx.textLayout.formats.TextLayoutFormat;
import mx.controls.SWFLoader;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.TextFlow;
private var textFlow:TextFlow;
private function onCreationComplete():void {
var container:Sprite = new Sprite();
canvas.rawChildren.addChild(container);
var containerController:ContainerController = new ContainerController(container, canvas.width, canvas.height);
textFlow=
new TextFlow();
textFlow.flowComposer.addController(containerController);
textFlow.interactionManager=
new EditManager();
textFlow.flowComposer.updateAllControllers();
}
private function onClick():void {
var charFormat:TextLayoutFormat = new TextLayoutFormat();
var containerFormat:TextLayoutFormat = new TextLayoutFormat();
var paragraphFormat:TextLayoutFormat = new TextLayoutFormat();
charFormat.fontSize=36;
textFlow.interactionManager.selectAll();
(textFlow.interactionManager
as EditManager).applyFormat(charFormat, paragraphFormat, containerFormat);
textFlow.interactionManager.refreshSelection();
textFlow.flowComposer.updateAllControllers();
}
]]>
</mx:Script>
<mx:Canvas id="canvas"
width="
200"
height="
200" borderStyle="solid"/>
<mx:Button id="button"
label="
Push me"
click="onClick()"
/>
</mx:Application>
When you click the button new font size is set. But the cursor in text field is not changed to a bigger one until I start editing. Also if to look at the textFlow internals in debugger you can see that new font size is not set...
How can I force this?
Kind Regards
