Package | flashx.textLayout.edit |
Class | public class EditManager |
Inheritance | EditManager SelectionManager Object |
Implements | IEditManager |
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
To enable text flow editing, assign an EditManager object to the interactionManager
property of the TextFlow object. The edit manager handles changes to the text (such as insertions,
deletions, and format changes). Changes are reversible if the edit manager has an undo manager. The edit
manager triggers the recomposition and display of the text flow, as necessary.
See also
Property | Defined By | ||
---|---|---|---|
absoluteEnd : int [read-only]
The text position of the end of the selection, as an offset from the start of the text flow. | SelectionManager | ||
absoluteStart : int [read-only]
The text position of the start of the selection, as an offset from the start of the text flow. | SelectionManager | ||
activePosition : int [read-only]
The active point of the selection. | SelectionManager | ||
anchorPosition : int [read-only]
The anchor point of the selection. | SelectionManager | ||
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
currentSelectionFormat : SelectionFormat [read-only]
The current SelectionFormat object. | SelectionManager | ||
editingMode : String [read-only]
The editing mode. | SelectionManager | ||
focused : Boolean [read-only]
Indicates whether a container in the text flow has the focus. | SelectionManager | ||
focusedSelectionFormat : SelectionFormat
The SelectionFormat object used to draw the selection in a focused container. | SelectionManager | ||
inactiveSelectionFormat : SelectionFormat
The SelectionFormat object used to draw the selection when it is not in the active window. | SelectionManager | ||
overwriteMode : Boolean = false [static]
Indicates whether overwrite mode is on or off. | EditManager | ||
prototype : Object [static]
A reference to the prototype object of a class or function object. | Object | ||
textFlow : flashx.textLayout.elements:TextFlow
The TextFlow object managed by this selection manager. | SelectionManager | ||
undoManager : IUndoManager [read-only]
The IUndoManager assigned to this edit manager. | EditManager | ||
unfocusedSelectionFormat : SelectionFormat
The SelectionFormat object used to draw the selection when it is not in a focused container, but is in
the active window. | SelectionManager | ||
windowActive : Boolean [read-only]
Indicates whether the window associated with the text flow is active. | SelectionManager |
Method | Defined By | ||
---|---|---|---|
EditManager(undoManager:IUndoManager = null)
Creates an EditManager object. | EditManager | ||
Processes an activate event. | SelectionManager | ||
applyContainerFormat(containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Applies container styles to any containers in the selection. | EditManager | ||
applyFormat(leafFormat:flashx.textLayout.formats:ITextLayoutFormat, paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Changes the formats of the specified (or current) selection. | EditManager | ||
applyFormatToElement(targetElement:FlowElement, format:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Applies styles to the specified element. | EditManager | ||
applyLeafFormat(characterFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Changes the format applied to the leaf elements in the
specified (or current) selection. | EditManager | ||
applyLink(href:String, targetString:String = null, extendToLinkBoundary:Boolean = false, operationState:SelectionState = null):void
Transforms a selection into a link, or a link into normal text. | EditManager | ||
applyParagraphFormat(paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Applies paragraph styles to any paragraphs in the selection. | EditManager | ||
Transforms text into a TCY run, or a TCY run into non-TCY text. | EditManager | ||
Begins a new group of operations. | EditManager | ||
changeElementID(newID:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
Changes the ID of an element. | EditManager | ||
changeStyleName(newName:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
Changes the styleName of an element or part of an element. | EditManager | ||
Deletes the selected area and returns the deleted area in a TextScrap object. | EditManager | ||
Processes a deactivate event. | SelectionManager | ||
Deletes a range of text, or, if a point selection is given, deletes the next character. | EditManager | ||
Deletes the next word. | EditManager | ||
Deletes a range of text, or, if a point selection is given, deletes the previous character. | EditManager | ||
Deletes the previous word. | EditManager | ||
Deletes a range of text. | EditManager | ||
Executes a FlowOperation. | EditManager | ||
[override] | EditManager | ||
Ends a group of operations. | EditManager | ||
SelectionManager | |||
Processes a focusChange event. | SelectionManager | ||
Processes a focusIn event. | SelectionManager | ||
Processes a focusOut event. | SelectionManager | ||
Gets the character format attributes that are common to all characters in the current selection. | SelectionManager | ||
Gets the container format attributes that are common to all containers in the current selection. | SelectionManager | ||
Gets the paragraph format attributes that are common to all paragraphs in the current selection. | SelectionManager | ||
Gets the SelectionState object of the current selection. | SelectionManager | ||
Indicates whether an object has a specified property defined. | Object | ||
Indicates whether there is a selection. | SelectionManager | ||
insertInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void
Inserts an image. | EditManager | ||
Inserts text. | EditManager | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Indicates whether the selection covers a range of text. | SelectionManager | ||
Processes a keyDown event. | SelectionManager | ||
Processes a keyUp event. | SelectionManager | ||
Processes a menuSelect event. | SelectionManager | ||
modifyInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void
Modifies an existing inline graphic. | EditManager | ||
Processes a mouseDoubleClick event. | SelectionManager | ||
Processes a mouseDown event. | SelectionManager | ||
Processes a mouseMove event. | SelectionManager | ||
Processes a mouseOut event. | SelectionManager | ||
Processes a mouseOver event. | SelectionManager | ||
Processes a mouseUp event. | SelectionManager | ||
Processes a mouseWheel event. | SelectionManager | ||
Updates the selection manager when text is inserted or deleted. | SelectionManager | ||
Overwrites the selected text. | EditManager | ||
pasteTextScrap(scrapToPaste:flashx.textLayout.edit:TextScrap, operationState:SelectionState = null):void
Pastes the TextScrap into the selected area. | EditManager | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Reperforms the previous undone operation. | EditManager | ||
Redisplays the selection shapes. | SelectionManager | ||
SelectionManager | |||
SelectionManager | |||
Gives the focus to the first container in the selection. | SelectionManager | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Splits the paragraph at the current position. | EditManager | ||
Processes a TextEvent. | SelectionManager | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns the string representation of the specified object. | Object | ||
Reverses the previous operation. | EditManager | ||
Returns the primitive value of the specified object. | Object |
Method | Defined By | ||
---|---|---|---|
Update the display after an operation has modified it | EditManager |
overwriteMode | property |
public static var overwriteMode:Boolean = false
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Indicates whether overwrite mode is on or off.
If true
, then a keystroke overwrites the character following the cursor.
If false
, then a keystroke is inserted at the cursor location.
undoManager | property |
undoManager:IUndoManager
[read-only] Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
The IUndoManager assigned to this edit manager.
To allow edits to be undone (and redone), pass an IUndoManager instance to the EditManager constructor. The undo manager maintains a stack of operations that have been executed, and it can undo or redo individual operations.
Note: If the TextFlow is modified directly (not via calls to the EditManager, but directly via calls to the managed FlowElement objects), then the EditManager clears the undo stack to prevent the stack from getting out of sync with the current state.
public function get undoManager():IUndoManager
EditManager | () | Constructor |
public function EditManager(undoManager:IUndoManager = null)
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Creates an EditManager object.
Assign an EditManager object to the interactionManager
property
of a text flow to enable editing of that text flow. To enable support for undoing
and redoing changes, pass an IUndoManager instance to the EditManager constructor.
undoManager:IUndoManager (default = null ) — The UndoManager for the application
|
See also
var textFlow:TextFlow = new TextFlow(); textFlow.interactionManager = new EditManager( new UndoManager() );
applyContainerFormat | () | method |
public function applyContainerFormat(containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Applies container styles to any containers in the selection.
Any style properties in the format object that are null
are left unchanged.
Parameters
containerFormat:flashx.textLayout.formats:ITextLayoutFormat — the format to apply to the containers in the range
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
function useTwoColumns( selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:IEditManager = textFlow.interactionManager as IEditManager; var containerStyle:TextLayoutFormat = new TextLayoutFormat(); containerStyle.columnCount = 2; editManager.applyContainerFormat( containerStyle ); }
applyFormat | () | method |
public function applyFormat(leafFormat:flashx.textLayout.formats:ITextLayoutFormat, paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Changes the formats of the specified (or current) selection.
Executes an undoable operation that applies the new formats. Only style attributes set for the TextLayoutFormat objects are applied. Undefined attributes in the format objects are not changed.
Parameters
leafFormat:flashx.textLayout.formats:ITextLayoutFormat — the format to apply to leaf elements such as spans and inline graphics
| |
paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat — format to apply to paragraph elements
| |
containerFormat:flashx.textLayout.formats:ITextLayoutFormat — format to apply to the containers
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
function applyFormats( selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:IEditManager = textFlow.interactionManager as IEditManager; var containerStyle:TextLayoutFormat = new TextLayoutFormat(); containerStyle.columnCount = 2; var paraStyle:TextLayoutFormat = new TextLayoutFormat(); paraStyle.textAlign = TextAlign.JUSTIFY; var charStyle:TextLayoutFormat = new TextLayoutFormat(); charStyle.color = 0xff0000; editManager.applyFormat( charStyle, paraStyle, containerStyle ); }
applyFormatToElement | () | method |
public function applyFormatToElement(targetElement:FlowElement, format:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Applies styles to the specified element.
Any style properties in the format object that are null
are left unchanged.
Only styles that are relevant to the specified element are applied.
Parameters
targetElement:FlowElement — the element to which the styles are applied.
| |
format:flashx.textLayout.formats:ITextLayoutFormat — the format containing the styles to apply
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
applyLeafFormat | () | method |
public function applyLeafFormat(characterFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Changes the format applied to the leaf elements in the specified (or current) selection.
Executes an undoable operation that applies the new format to leaf elements such as SpanElement and InlineGraphicElement objects. Only style attributes set for the TextLayoutFormat objects are applied. Undefined attributes in the format object are changed.
Parameters
characterFormat:flashx.textLayout.formats:ITextLayoutFormat — the format to apply.
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
function makeRed( selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:IEditManager = textFlow.interactionManager as IEditManager; var charStyle:TextLayoutFormat = new TextLayoutFormat(); charStyle.color = 0xff0000; editManager.applyLeafFormat( charStyle ); }
applyLink | () | method |
public function applyLink(href:String, targetString:String = null, extendToLinkBoundary:Boolean = false, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Transforms a selection into a link, or a link into normal text.
Executes an undoable operation that creates or removes the link.
If a target
parameter is specified, it must be one of the following values:
In browser-hosted runtimes, a target of "_self" replaces the current html page. So, if the SWF content containing the link is in a page within a frame or frameset, the linked content loads within that frame. If the page is at the top level, the linked content opens to replace the original page. A target of "_blank" opens a new browser window with no name. A target of "_parent" replaces the parent of the html page containing the SWF content. A target of "_top" replaces the top-level page in the current browser window.
In other runtimes, such as Adobe AIR, the link opens in the user's default browser and the
target
parameter is ignored.
The extendToLinkBoundary
parameter determines how the edit manager
treats a selection that intersects with one or more existing links. If the parameter is
true
, then the operation is applied as a unit to the selection and the
whole text of the existing links. Thus, a single link is created that spans from
the beginning of the first link intersected to the end of the last link intersected.
In contrast, if extendToLinkBoundary
were false
in this situation,
the existing partially selected links would be split into two links.
Parameters
href:String — The uri referenced by the link.
| |
targetString:String (default = null ) — The target browser window of the link.
| |
extendToLinkBoundary:Boolean (default = false ) — Specifies whether to consolidate selection with any overlapping existing links, and then apply the change.
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
function makeLink( selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:IEditManager = textFlow.interactionManager as IEditManager; editManager.applyLink( "http://www.adobe.com" ); } function removeLink( selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:EditManager = textFlow.interactionManager as EditManager; editManager.applyLink( null, null, true ); }
applyParagraphFormat | () | method |
public function applyParagraphFormat(paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Applies paragraph styles to any paragraphs in the selection.
Any style properties in the format object that are null
are left unchanged.
Parameters
paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat — the format to apply to the selected paragraphs.
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
function justifyParagraph( selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:IEditManager = textFlow.interactionManager as IEditManager; var paraStyle:TextLayoutFormat = new TextLayoutFormat(); paraStyle.textAlign = TextAlign.JUSTIFY; editManager.applyParagraphFormat( paraStyle ); }
applyTCY | () | method |
public function applyTCY(tcyOn:Boolean, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Transforms text into a TCY run, or a TCY run into non-TCY text.
TCY, or tate-chuu-yoko, causes text to draw horizontally within a vertical line, and is used to make small blocks of non-Japanese text or numbers, such as dates, more readable in vertical text.
Parameters
tcyOn:Boolean — specify true to apply TCY to a text range, false to remove TCY.
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
function tcyOn( selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:IEditManager = textFlow.interactionManager as IEditManager; editManager.applyTCY( true ); } function tcyOff( selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:EditManager = textFlow.interactionManager as EditManager; editManager.applyTCY( false ); }
beginCompositeOperation | () | method |
public function beginCompositeOperation():void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Begins a new group of operations.
All operations executed after the call to beginCompositeOperation()
, and before the
matching call to endCompositeOperation()
are executed and grouped together as a single
operation that can be undone as a unit.
A beginCompositeOperation
/endCompositeOperation
block can be nested inside another
beginCompositeOperation
/endCompositeOperation
block.
beginCompositeOperation()
and endCompositeOperation()
functions were not used,
then each of the suboperations would have to be undone separately rather than as a group.
function insertGraphic( source:Object, width:Object, height:Object, float:String, selection:SelectionState ):void { var editManager:IEditManager = selection.textFlow.interactionManager as IEditManager; editManager.beginCompositeOperation(); editManager.deleteText( selection ); var changedSelection:SelectionState = new SelectionState( selection.textFlow, selection.anchorPosition, selection.anchorPosition ); editManager.splitParagraph( changedSelection ); changedSelection = new SelectionState( changedSelection.textFlow, changedSelection.anchorPosition + 1, changedSelection.anchorPosition + 1); editManager.insertInlineGraphic( source, width, height, float, changedSelection ); changedSelection = new SelectionState( changedSelection.textFlow, changedSelection.anchorPosition + 1, changedSelection.anchorPosition + 1); editManager.splitParagraph( changedSelection ); editManager.endCompositeOperation(); }
changeElementID | () | method |
public function changeElementID(newID:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Changes the ID of an element.
If the relativeStart
or relativeEnd
parameters are set (to
anything other than the default values), then the element is split. The parts of the element
outside this range retain the original ID. Setting both the relativeStart
and
relativeEnd
parameters creates elements with duplicate IDs.
Parameters
newID:String — the new ID value
| |
targetElement:FlowElement — the element to modify
| |
relativeStart:int (default = 0 ) — an offset from the beginning of the element at which to split the element when assigning the new ID
| |
relativeEnd:int (default = -1 ) — an offset from the end of the element at which to split the element when assigning the new ID
| |
operationState:SelectionState (default = null ) — specifies the selection to restore when undoing this operation;
if null , the operation saves the current selection.
|
function changeParagraphID( id:String, selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:IEditManager = textFlow.interactionManager as IEditManager; var selectedRange:ElementRange = ElementRange.createElementRange( selection.textFlow, selection.absoluteStart, selection.absoluteEnd ); editManager.changeElementID( id, selectedRange.firstParagraph, 0, -1, selection ); }
changeStyleName | () | method |
public function changeStyleName(newName:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Changes the styleName of an element or part of an element.
If the relativeStart
or relativeEnd
parameters are set (to
anything other than the default values), then the element is split. The parts of the element
outside this range retain the original style.
Parameters
newName:String — the name of the new style.
| |
targetElement:FlowElement — specifies the element to change.
| |
relativeStart:int (default = 0 ) — an offset from the beginning of the element at which to split the element when assigning the new style
| |
relativeEnd:int (default = -1 ) — an offset from the end of the element at which to split the element when assigning the new style
| |
operationState:SelectionState (default = null ) — specifies the selection to restore when undoing this operation;
if null , the operation saves the current selection.
|
function changeParagraphStyle( styleName:String, selection:SelectionState ):void { var textFlow:TextFlow = selection.textFlow; var editManager:IEditManager = textFlow.interactionManager as IEditManager; var selectedRange:ElementRange = ElementRange.createElementRange( selection.textFlow, selection.absoluteStart, selection.absoluteEnd ); editManager.changeElementID( styleName, selectedRange.firstParagraph, 0, -1, selection ); }
cutTextScrap | () | method |
public function cutTextScrap(operationState:SelectionState = null):flashx.textLayout.edit:TextScrap
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Deletes the selected area and returns the deleted area in a TextScrap object.
The resulting TextScrap can be posted to the system clipboard or used in a
subsequent pasteTextOperation()
operation.
Parameters
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
flashx.textLayout.edit:TextScrap — the TextScrap that was cut
|
See also
var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 4, 7 ); var scrap:TextScrap = editManager.cutTextScrap(); //Displays: How now brown cow.
deleteNextCharacter | () | method |
public function deleteNextCharacter(operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Deletes a range of text, or, if a point selection is given, deletes the next character.
Parameters
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown crow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 15, 15 ); editManager.deleteNextCharacter(); //displays: How now brown cow.
deleteNextWord | () | method |
public function deleteNextWord(operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Deletes the next word.
If a range is selected, the first word of the range is deleted.
Parameters
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 3, 3 ); editManager.deleteNextWord(); //displays: How now brown cow.
deletePreviousCharacter | () | method |
public function deletePreviousCharacter(operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Deletes a range of text, or, if a point selection is given, deletes the previous character.
Parameters
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown crow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 16, 16 ); editManager.deletePreviousCharacter(); //displays: How now brown cow.
deletePreviousWord | () | method |
public function deletePreviousWord(operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Deletes the previous word.
If a range is selected, the first word of the range is deleted.
Parameters
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 7, 7 ); editManager.deletePreviousWord(); //displays: How now brown cow.
deleteText | () | method |
public function deleteText(operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Deletes a range of text.
Parameters
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 4, 7 ); editManager.deleteText(); //displays: How now brown cow.
doOperation | () | method |
public function doOperation(operation:FlowOperation):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Executes a FlowOperation.
The doOperation()
method is called by IEditManager functions that
update the text flow. You do not typically need to call this function directly unless
you create your own custom operations.
This function proceeds in the following steps:
true
or false
.
False
indicates that no changes were made.Exception handling: If the operation throws an exception, it is caught and the error is attached to the flowOperationEnd event. If the event is not canceled the error is rethrown.
Parameters
operation:FlowOperation — a FlowOperation object
|
var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 4, 4 ); var selectionState:SelectionState = editManager.getSelectionState(); var insertOperation:InsertTextOperation = new InsertTextOperation( selectionState, "now " ); editManager.doOperation( insertOperation );
editHandler | () | method |
endCompositeOperation | () | method |
public function endCompositeOperation():void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Ends a group of operations.
All operations executed since the last call to beginCompositeOperation()
are
grouped as a CompositeOperation that is then completed. This CompositeOperation object is added
to the undo stack or, if this composite operation is nested inside another composite operation,
added to the parent operation.
beginCompositeOperation()
and endCompositeOperation()
functions were not used,
then each of the suboperations would have to be undone separately rather than as a group.
function insertGraphic( source:Object, width:Object, height:Object, float:String, selection:SelectionState ):void { var editManager:IEditManager = selection.textFlow.interactionManager as IEditManager; editManager.beginCompositeOperation(); editManager.deleteText( selection ); var changedSelection:SelectionState = new SelectionState( selection.textFlow, selection.anchorPosition, selection.anchorPosition ); editManager.splitParagraph( changedSelection ); changedSelection = new SelectionState( changedSelection.textFlow, changedSelection.anchorPosition + 1, changedSelection.anchorPosition + 1); editManager.insertInlineGraphic( source, width, height, float, changedSelection ); changedSelection = new SelectionState( changedSelection.textFlow, changedSelection.anchorPosition + 1, changedSelection.anchorPosition + 1); editManager.splitParagraph( changedSelection ); editManager.endCompositeOperation(); }
insertInlineGraphic | () | method |
public function insertInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Inserts an image.
The source of the image can be a string containing a URI, URLRequest object, a Class object representing an embedded asset, or a DisplayObject instance.
The width and height values can be the number of pixels, a percent, or the string, 'auto', in which case the actual dimension of the graphic is used.
Set the float
to one of the constants defined in the Float class to specify whether
the image should be displayed to the left or right of any text or inline with the text.
Parameters
source:Object — can be either a String interpreted as a uri, a Class interpreted as the class of an Embed DisplayObject,
a DisplayObject instance or a URLRequest.
| |
width:Object — width of the image to insert (number, percent, or 'auto')
| |
height:Object — height of the image to insert (number, percent, or 'auto')
| |
options:Object (default = null ) — none supported.
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
See also
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 0, 0 ); editManager.insertInlineGraphic( createGraphic(), 6, 6, "none" ); function createGraphic():DisplayObject { var shape:Shape = new Shape(); shape.graphics.beginFill( 0x993366 ); shape.graphics.drawCircle( 5, 4, 6 ); return shape; }
insertText | () | method |
public function insertText(text:String, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Inserts text.
Inserts the text at a position or range in the text. If the location supplied in the
operationState
parameter is a range (or the parameter is null
and the
current selection is a range), then the text currently in the range
is replaced by the inserted text.
Parameters
text:String — the string to insert
| |
operationState:SelectionState (default = null ) — specifies the text in the flow to which this operation applies;
if null , the operation applies to the current selection.
|
var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 4, 4 ); editManager.insertText( "now " );
modifyInlineGraphic | () | method |
public function modifyInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Modifies an existing inline graphic.
Set unchanging properties to the values in the original graphic. (Modifying an existing graphic object is typically more efficient than deleting and recreating one.)
Parameters
source:Object — can be either a String interpreted as a uri, a Class interpreted as the class of an Embed DisplayObject,
a DisplayObject instance or a URLRequest.
| |
width:Object — new width for the image (number or percent)
| |
height:Object — new height for the image (number or percent)
| |
options:Object (default = null ) — none supported
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
width
and height
properties of the inline graphic to
stretch it into an ellipse:
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 0, 0 ); editManager.insertInlineGraphic( createGraphic(), 6, 6, "none" ); editManager.setSelection( 0, 1 ); var selection:SelectionState = editManager.getSelectionState(); editManager.modifyInlineGraphic( null, '12', '5', 'none', selection ); function createGraphic():DisplayObject { var shape:Shape = new Shape(); shape.graphics.beginFill( 0x993366 ); shape.graphics.drawCircle( 4, 4, 6 ); return shape; }
overwriteText | () | method |
public function overwriteText(text:String, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Overwrites the selected text.
If the selection is a point selection, the first character is overwritten by the new text.
Parameters
text:String — the string to insert
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
var textFlow:TextFlow = TextConverter.importToFlow( "How zzz brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 4, 6 ); editManager.overwriteText( "now" ); //Displays: How now brown cow.
pasteTextScrap | () | method |
public function pasteTextScrap(scrapToPaste:flashx.textLayout.edit:TextScrap, operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Pastes the TextScrap into the selected area.
If a range of text is specified, the text in the range is deleted.
Parameters
scrapToPaste:flashx.textLayout.edit:TextScrap — the TextScrap to paste
| |
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
See also
var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow now.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:EditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 13, 17 ); var scrap:TextScrap = editManager.cutTextScrap(); editManager.setSelection( 3, 3 ); editManager.pasteTextScrap( scrap ); //Displays: How now brown cow.
redo | () | method |
public function redo():void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Reperforms the previous undone operation.
Note: If the IUndoManager associated with this IEditManager is also associated with another IEditManager, then it is possible that the redo operation associated with the other IEditManager is the one redone. This can happen if the FlowOperation of another IEditManager is on top of the redo stack.
This function does nothing if undo is not turned on.
See also
function redo( textFlow:TextFlow ):void { if( textFlow.interactionManager is IEditManager ) { IEditManager( textFlow.interactionManager ).redo(); } }
splitParagraph | () | method |
public function splitParagraph(operationState:SelectionState = null):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Splits the paragraph at the current position.
If a range of text is specified, the text in the range is deleted.
Parameters
operationState:SelectionState (default = null ) — specifies the text to which this operation applies;
if null , the operation applies to the current selection.
|
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT ); textFlow.flowComposer = new StandardFlowComposer(); textFlow.flowComposer.addController( new ContainerController( this )); var editManager:IEditManager = new EditManager( new UndoManager() ); textFlow.interactionManager = editManager; textFlow.flowComposer.updateAllControllers(); editManager.setSelection( 8, 8 ); editManager.splitParagraph(); //Displays: How now // brown cow.
undo | () | method |
public function undo():void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Reverses the previous operation.
Note: If the IUndoManager associated with this IEditManager is also associated with another IEditManager, then it is possible that the undo operation associated with the other IEditManager is the one undone. This can happen if the FlowOperation of another IEditManager is on top of the undo stack.
This function does nothing if undo is not turned on.
See also
function undo( textFlow:TextFlow ):void { if( textFlow.interactionManager is IEditManager ) { IEditManager( textFlow.interactionManager ).undo(); } }
updateAllControllers | () | method |
protected function updateAllControllers():void
Update the display after an operation has modified it
This example shows the use of the EditManager
class.
It sets up a Div element that contains a paragraph with text. The Div is added to
a TextFlow object (tf), which is composed to a display object container. An UndoManager
object (um) is assigned to a new EditManager, which in turn is assigned as the the TextFlow's
interactionManager
.
Four existing button objects (undo, redo, editable, and readonly) are assumed to be on the stage in this example. Event listeners assigned to these buttons are used to manipulate the EditManager.
package { import flash.display.Sprite; import flashx.textLayout.elements.TextFlow; import flashx.textLayout.edit.EditManager; import flashx.textLayout.edit.UndoManager; import flashx.textLayout.elements.DivElement; import flashx.textLayout.elements.ParagraphElement; import flashx.textLayout.elements.SpanElement; import flashx.textLayout.container.ContainerController; import flash.events.MouseEvent; public class EditManager_ex extends Sprite { private var tf:TextFlow; private var em:EditManager; private var um:UndoManager; public function EditManager_ex() { //define TextFlow and manager objects tf = new TextFlow(); um = new UndoManager(); um.undoActive = true; em = new EditManager(um); tf.interactionManager = em; //define elements to contain text var d:DivElement = new DivElement(); var p:ParagraphElement = new ParagraphElement(); var s:SpanElement = new SpanElement(); s.text ="This is sample text for the EditManager example."; //add these elements to the TextFlow p.addChild(s); d.addChild(p); tf.addChild(d); //compose TextFlow to display tf.flowComposer.addController(new ContainerController(this,600,600)); tf.flowComposer.updateAllContainers(); //add event handlers to existing button objects editable.addEventListener(MouseEvent.CLICK, updateToBeEditable); readonly.addEventListener(MouseEvent.CLICK, updateToReadOnly); undo.addEventListener(MouseEvent.CLICK, undoRecentEdit); redo.addEventListener(MouseEvent.CLICK, redoRecentEdit); } private function updateToBeEditable(me:MouseEvent):void{ undo.enabled = true; tf.interactionManager = em; } private function updateToReadOnly(me:MouseEvent):void{ undo.enabled = false; redo.enabled = false; tf.interactionManager = null; um.clear(); } private function undoRecentEdit(me:MouseEvent):void{ if (um.canUndo()){ em.undo(); redo.enabled = true; } } private function redoRecentEdit(me:MouseEvent):void{ if(um.canRedo()){ em.redo(); redo.enabled = false; } } } }