Text Layout Framework columncount Undo problem
Text Layout Framework columncount Undo problem ::
The number of times columncount is changed it gets applied to textflow
and those number of operation is stored in undoStack(UndoManger).But when i
undo it, it comes back to intial state, without undoin step by step.
I have given my source code..
Y so or any other alternative to achieve this..
Thanx in advance..
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init()">
<fx:Script>
<![CDATA[
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.ITextImporter;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.ISelectionManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.InlineGraphicElement;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.events.SelectionEvent;
import flashx.textLayout.events.StatusChangeEvent;
import flashx.textLayout.formats.Direction;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.undo.UndoManager;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.CheckBox;
import mx.events.FlexEvent;
import mx.events.SliderEvent;
import spark.components.Group;
import spark.components.TextArea;
import spark.core.SpriteVisualElement;
public var directions:ArrayCollection = new
ArrayCollection(
[
{label:"Left-to-Right",
data:Direction.LTR},
{label:"Right-to-Left",
data:Direction.RTL}
]
);
private var _textContainer:SpriteVisualElement = null;
private static const textInput:XML = <TextFlow
xmlns="http://ns.adobe.com/textLayout/2008">
<div>
<p><span>The Text Layout Framework is
an extensible library, built on the new text engine in Adobe Flash Player 10,
which delivers advanced, easy-to-integrate typographic and text layout features
for rich, sophisticated and innovative typography on the web.
Some benefits provided by this framework
include: 1) rich typographical controls, including kerning, ligatures,
typographic case, digit case, digit width and discretionary hyphens
2) cut, copy, paste, undo and standard keyboard
and mouse gestures for editing 3) selection, editing and flowing text across
multiple columns and linked containers
4) bidirectional text, vertical text and over
30 writing scripts including Arabic, Hebrew, Chinese, Japanese, Korean, Thai,
Lao, Vietnamese, and others
5) vertical text, Tate-Chu-Yoko (horizontal
within vertical text) and justifier for East Asian typography. Try editing this
text and playing with the options below! Notice an inline image is also
included.</span></p>
</div>
</TextFlow>;
private var _textFlow:TextFlow;
private function init():void {
_textContainer = new SpriteVisualElement();
canvas.addElement(_textContainer);
var importer:ITextImporter =
TextConverter.getImporter(TextConverter.TEXT_LAYOUT_FORMAT);
_textFlow = importer.importToFlow(textInput);
_textFlow.flowComposer.addController(new
ContainerController(_textContainer, canvas.width-40, canvas.height));
_textFlow.interactionManager = new
EditManager(new UndoManager());
_textFlow.flowComposer.updateAllControllers();
}
private function changeNoColumns(event:Event):void {
var tlf:TextLayoutFormat = new
TextLayoutFormat();
tlf.columnCount = cols.value;
tlf.columnGap = 15;
tlf.direction = direction.selectedItem.data;
var em:EditManager =
_textFlow.interactionManager as EditManager;
em.selectAll();
(_textFlow.interactionManager as
EditManager).applyFormat(tlf,tlf,tlf);
_textFlow.flowComposer.updateAllControllers();
}
protected function
undo_clickHandler(event:MouseEvent):void
{
var em:EditManager =
_textFlow.interactionManager as EditManager;
trace("Can undo " + em.undoManager.canUndo() +
" can redo " + em.undoManager.canRedo());
em.undo();
}
protected function
redo_clickHandler(event:MouseEvent):void
{
var em:EditManager =
_textFlow.interactionManager as EditManager;
trace("Can undo " + em.undoManager.canUndo() +
" can redo " + em.undoManager.canRedo());
em.redo();
}
]]>
</fx:Script>
<s:Panel title="Text Layout Framework Sample" width="100%"
height="100%">
<s:layout>
<s:VerticalLayout paddingTop="8" paddingLeft="8"/>
</s:layout>
<s:VGroup>
<s:Group id="canvas" width="600" height="200" />
<s:HGroup width="100%" verticalAlign="middle">
<s:Label text="# Columns:"/>
<s:NumericStepper id="cols" minimum="1"
maximum="20" snapInterval="1" change="changeNoColumns(event)" />
<s:Label text="Text Direction:"/>
<s:DropDownList id="direction"
change="changeTextDirection(event)" dataProvider="{directions}"
selectedItem="{directions[0]}"/>
<s:Button label="Undo"
click="undo_clickHandler(event)"/>
<s:Button label="Redo"
click="redo_clickHandler(event)"/>
</s:HGroup>
</s:VGroup>
</s:Panel>
</s:WindowedApplication>
