| 包 | flashx.textLayout.edit |
| 类 | public class EditManager |
| 继承 | EditManager SelectionManager Object |
| 实现 | IEditManager |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
要启用文本流编辑功能,请将一个 EditManager 对象指定给 TextFlow 对象的 interactionManager 属性。编辑管理器可以处理对文本进行的更改(例如插入、删除和更改格式)。如果编辑管理器具有撤消管理器,则可以撤消这些更改。必要时,编辑管理器会触发文本流的重新合成和显示。
EditManager 类支持以下键盘快捷键:
| 键 | 结果 |
|---|---|
| ctrl-z | 撤销 |
| ctrl-y | 重做 |
| ctrl-backspace | deletePreviousWord |
| ctrl-delete | deleteNextWord |
| alt+delete | deleteNextWord |
| ctrl+alt-delete | deleteNextWord |
| ctrl-shift-连字符 | 插入任意连字符 |
| ctrl+backspace | deletePreviousWord |
| alt+backspace | deletePreviousWord |
| ctrl+alt-backspace | deletePreviousWord |
| Insert | 切换 overWriteMode |
| Backspace | deletePreviousCharacter |
| Enter | 如果 textFlow.configuration.manageEnterKey 在列表中,它将创建一个新列表项,否则将创建一个新段落 |
| shift-ENTER | 如果 textFlow.configuration.manageEnterKey 创建一个新段落 |
| Tab | 如果 textFlow.configuration.manageTabKey 在一个列表中,它将创建一个嵌套列表,否则将插入一个 TAB 或者使用 TAB 覆盖下一个字符 |
| shift-TAB | 如果 textFlow.configuration.manageTabKey 在列表的第一项中,则它会将该项移出列表(提升该项) |
请注意:以下组合键在 Windows 中无效:alt-backspace、alt-delete、ctrl+alt-backspace 和 ctrl+alt-delete。这些组合键不会生成运行时事件。
相关 API 元素
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
EditManager(undoManager:IUndoManager = null)
创建 EditManager 对象。 | EditManager | ||
![]() |
处理 activate 事件。 | SelectionManager | |
applyContainerFormat(containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
将容器样式应用于所选项目中的任何容器。 | EditManager | ||
applyFormat(leafFormat:flashx.textLayout.formats:ITextLayoutFormat, paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
更改指定(或当前)选择部分的格式。 | EditManager | ||
applyFormatToElement(targetElement:FlowElement, format:flashx.textLayout.formats:ITextLayoutFormat, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
将样式应用于指定元素。 | EditManager | ||
applyLeafFormat(characterFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
更改应用于指定(或当前)选择部分中叶元素的格式。 | EditManager | ||
applyLink(href:String, targetString:String = null, extendToLinkBoundary:Boolean = false, operationState:SelectionState = null):LinkElement
将选择部分转换为一个链接,或将链接转换为普通文本。 | EditManager | ||
applyParagraphFormat(paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
将段落样式应用于所选项目中的任何段落。 | EditManager | ||
将文本转换为 TCY 串或将 TCY 串转换为非 TCY 文本。 | EditManager | ||
开始一组新操作。 | EditManager | ||
changeElementID(newID:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
更改元素的 ID。 | EditManager | ||
changeStyleName(newName:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void 自以下版本起不推荐使用: 2.0: 请使用 applyFormatToElement
更改整个元素或部分元素的 styleName。 | EditManager | ||
changeTypeName(newName:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
更改整个元素或部分元素的 typeName。 | EditManager | ||
clearFormat(leafFormat:flashx.textLayout.formats:ITextLayoutFormat, paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
对指定(或当前)所选项目的格式取消定义。 | EditManager | ||
clearFormatOnElement(targetElement:FlowElement, format:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void
对指定元素的样式取消定义。 | EditManager | ||
createDiv(parent:FlowGroupElement = null, format:flashx.textLayout.formats:ITextLayoutFormat = null, operationState:SelectionState = null):DivElement 在同时包含范围的开始和结束点的最低公共父元素位置,创建包含在 operationState 中指定的整个范围的新 DivElement。 | EditManager | ||
createList(parent:FlowGroupElement = null, format:flashx.textLayout.formats:ITextLayoutFormat = null, operationState:SelectionState = null):ListElement 在同时包含范围的开始和结束点的最低公共父元素位置,创建包含在 operationState 中指定的整个范围的新 ListElement。 | EditManager | ||
createSubParagraphGroup(parent:FlowGroupElement = null, format:flashx.textLayout.formats:ITextLayoutFormat = null, operationState:SelectionState = null):SubParagraphGroupElement 在同时包含范围的开始和结束点的最低公共父元素位置,创建包含在 operationState 中指定的整个范围的新 SubParagraphGroupElement。 | EditManager | ||
删除选择的区域并在 TextScrap 对象中返回删除的区域。 | EditManager | ||
![]() |
处理 deactivate 事件。 | SelectionManager | |
删除某一范围内的文本,或者,如果进行了点选择,则删除下一个字符。 | EditManager | ||
删除下一个字。 | EditManager | ||
删除某一范围内的文本,或者,如果进行了点选择,则删除上一个字符。 | EditManager | ||
删除上一个字。 | EditManager | ||
删除某一范围内的文本。 | EditManager | ||
[覆盖]
执行 FlowOperation。 | EditManager | ||
![]() |
处理 edit 事件。 | SelectionManager | |
结束一组操作。 | EditManager | ||
![]() | SelectionManager | ||
![]() |
处理 focusChange 事件。 | SelectionManager | |
![]() |
处理 focusIn 事件。 | SelectionManager | |
![]() |
处理 focusOut 事件。 | SelectionManager | |
![]() | getCommonCharacterFormat(range:flashx.textLayout.elements:TextRange = null):flashx.textLayout.formats:TextLayoutFormat
获取对于指定的文本范围或当前所选项目中的所有字符都通用的字符格式属性。 | SelectionManager | |
![]() | getCommonContainerFormat(range:flashx.textLayout.elements:TextRange = null):flashx.textLayout.formats:TextLayoutFormat
获取对于指定的文本范围或当前所选项目中的所有容器都通用的容器格式属性。 | SelectionManager | |
![]() | getCommonParagraphFormat(range:flashx.textLayout.elements:TextRange = null):flashx.textLayout.formats:TextLayoutFormat
获取对于指定的文本范围或当前选区中的所有段落都通用的段落格式属性。 | SelectionManager | |
![]() |
获取当前所选内容的 SelectionState 对象。 | SelectionManager | |
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
![]() |
指示是否进行了选择。 | SelectionManager | |
![]() |
处理 imeStartComposition 事件。
| SelectionManager | |
insertInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):InlineGraphicElement
插入图像。 | EditManager | ||
插入文本。 | EditManager | ||
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
指示选择时是否涵盖某一文本范围。 | SelectionManager | |
![]() |
处理 keyDown 事件。 | SelectionManager | |
![]() |
处理 keyFocusChange 事件。 | SelectionManager | |
![]() |
处理 keyUp 事件。 | SelectionManager | |
![]() |
处理 menuSelect 事件。 | SelectionManager | |
modifyInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void
修改现有内嵌图形。 | EditManager | ||
![]() |
处理 mouseDoubleClick 事件。 | SelectionManager | |
![]() |
处理 mouseDown 事件。 | SelectionManager | |
![]() |
处理 mouseMove 事件。 | SelectionManager | |
![]() |
处理 mouseOut 事件。 | SelectionManager | |
![]() |
处理 mouseOver 事件。 | SelectionManager | |
![]() |
处理 mouseUp 事件。 | SelectionManager | |
![]() |
处理 mouseWheel 事件。 | SelectionManager | |
moveChildren(source:FlowGroupElement, sourceIndex:int, numChildren:int, destination:FlowGroupElement, destinationIndex:int, selectionState:SelectionState = null):void 将一组 FlowElement 从一个 FlowGroupElement 移动至另一个 FlowGroupElement。 | EditManager | ||
![]() |
插入或删除文本时更新选择管理器。 | SelectionManager | |
覆盖所选文本。 | EditManager | ||
pasteTextScrap(scrapToPaste:flashx.textLayout.edit:TextScrap, operationState:SelectionState = null):void
将 TextScrap 粘贴到选定区域。 | EditManager | ||
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
执行上一个撤消的操作。 | EditManager | ||
![]() |
重新显示选择形状。 | SelectionManager | |
![]() | SelectionManager | ||
![]() | SelectionManager | ||
![]() |
将焦点设置到所选内容中的第一个容器。 | SelectionManager | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
设置当前选定内容的 SelectionState 对象。 | SelectionManager | |
![]() |
处理 softKeyboardActivating 事件
| SelectionManager | |
在指定位置拆分目标元素,同时在当前元素后创建新元素。 | EditManager | ||
在当前位置拆分段落,同时在当前段落后创建新段落。 | EditManager | ||
![]() |
处理 TextEvent。 | SelectionManager | |
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
恢复上一个操作。 | EditManager | ||
| EditManager | |||
![]() |
返回指定对象的原始值。 | Object | |
allowDelayedOperations | 属性 |
delayUpdates | 属性 |
overwriteMode | 属性 |
public static var overwriteMode:Boolean = false| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
指示启用还是禁用覆盖模式。
如果为 true,则一个键击字符将覆盖光标后的字符。如果为 false,则会在光标位置插入一个键击字符。
undoManager | 属性 |
undoManager:IUndoManager [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
指定给该编辑管理器的 IUndoManager。
要允许撤消(和重做)编辑,请将一个 IUndoManager 实例传递给 EditManager 构造函数。撤消管理器维护一个包含已执行操作的堆栈,并可以取消或重做单个操作。
注意:如果直接修改了 TextFlow(不是通过调用 EditManager 而是直接通过调用受管的 FlowElement 对象),则 EditManager 会清除撤消堆栈,以避免堆栈与当前状态不同步。
实现
public function get undoManager():IUndoManagerEditManager | () | 构造函数 |
public function EditManager(undoManager:IUndoManager = null)| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
创建 EditManager 对象。
将 EditManager 对象指定给文本流的 interactionManager 属性以启用对该文本流的编辑。
要支持撤消和重做更改,可将一个 IUndoManager 实例传递给 EditManager 构造函数。可使用 flashx.undo.UndoManager 类或创建一个自定义 IUndoManager 实例。使用自定义 IUndoManager 实例将 Text Layout Framework 更改与不是 UndoManager 类的实例的现有撤消管理器集成。要创建自定义 IUndoManager 实例,请确保用于定义撤消管理器的类实现 IUndoManager 接口。
undoManager:IUndoManager (default = null) — 应用程序的 UndoManager
|
相关 API 元素
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
public class EditManager_constructor
{
// Create a new TextFlow that is editable and undoable.
static public function createEditableTextFlow():TextFlow
{
var textFlow:TextFlow = new TextFlow();
textFlow.interactionManager = new EditManager( new UndoManager() );
return textFlow;
}
}
}
applyContainerFormat | () | 方法 |
public function applyContainerFormat(containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
将容器样式应用于所选项目中的任何容器。
格式对象中所有 null 样式属性将不会改变。
参数
containerFormat:flashx.textLayout.formats:ITextLayoutFormat — 要应用于范围内容器的格式
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.TextLayoutFormat;
public class EditManager_applyContainerFormat
{
public function EditManager_applyContainerFormat( 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 | () | 方法 |
public function applyFormat(leafFormat:flashx.textLayout.formats:ITextLayoutFormat, paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
更改指定(或当前)选择部分的格式。
执行一个不可撤消的操作,该操作将应用新格式。只应用为 TextLayoutFormat 对象设置的样式属性。格式对象中的未定义属性没有改变。
参数
leafFormat:flashx.textLayout.formats:ITextLayoutFormat — 要应用于叶元素(例如跨距和内嵌图形)的格式。
| |
paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat — 要应用于段落元素的格式。
| |
containerFormat:flashx.textLayout.formats:ITextLayoutFormat — 要应用于容器的格式。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.TextAlign;
import flashx.textLayout.formats.TextLayoutFormat;
public class EditManager_applyFormat
{
public function EditManager_applyFormat( 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 | () | 方法 |
public function applyFormatToElement(targetElement:FlowElement, format:flashx.textLayout.formats:ITextLayoutFormat, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
将样式应用于指定元素。
格式对象中所有 null 样式属性将不会改变。只有与指定元素相关的样式才会被应用。
参数
targetElement:FlowElement — 将应用样式的元素。
| |
format:flashx.textLayout.formats:ITextLayoutFormat — 包含要应用的样式的格式。
| |
relativeStart:int (default = 0) — 分配新格式时,距离拆分元素时所在的元素开头的偏移。
| |
relativeEnd:int (default = -1) — 应用新格式时,距离拆分元素时所在的元素开头的偏移。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
applyLeafFormat | () | 方法 |
public function applyLeafFormat(characterFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
更改应用于指定(或当前)选择部分中叶元素的格式。
执行一个不可撤消的操作,该操作将新格式应用于叶元素,例如 SpanElement 和 InlineGraphicElement 对象。只应用为 TextLayoutFormat 对象设置的样式属性。格式对象中的未定义属性已改变。
参数
characterFormat:flashx.textLayout.formats:ITextLayoutFormat — 要应用的格式。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.TextLayoutFormat;
public class EditManager_applyLeafFormat
{
public function EditManager_applyLeafFormat(selection:SelectionState)
{
var textFlow:TextFlow = selection.textFlow;
var editManager:IEditManager = textFlow.interactionManager as IEditManager;
var charStyle:TextLayoutFormat = new TextLayoutFormat();
charStyle.color = 0xff0000;
editManager.applyLeafFormat( charStyle );
}
}
}
applyLink | () | 方法 |
public function applyLink(href:String, targetString:String = null, extendToLinkBoundary:Boolean = false, operationState:SelectionState = null):LinkElement| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10 - + 10.2, AIR 1.5 |
将选择部分转换为一个链接,或将链接转换为普通文本。
执行一个创建或删除链接的不可撤消的操作。
如果指定了 target 参数,则必须为下列值之一:
- "_self"
- "_blank"
- "_parent"
- "_top"
在浏览器承载的运行时中,目标为 "_self" 时将替换当前的 html 页。因此,如果包含链接的 SWF 内容位于某页中的一个框架或框架集内,则链接的内容将加载在该框架内。如果页面位于顶层,则链接的内容打开时会替换原始页。目标为 "_blank" 时将打开一个新的浏览器窗口(未命名)。目标为 "_parent" 时将替换包含 SWF 内容的 html 页的父代。目标为 "_top" 时将替换当前浏览器窗口中的顶层页。
在其它运行时中,例如 Adobe AIR 中,链接在用户的默认浏览器中打开,并忽略 target 参数。
extendToLinkBoundary 参数确定编辑管理器如何处理与一个或多个现有链接相交的选择部分。如果该参数为 true,则该操作作为一个单元应同时应用于选择部分及现有链接的全部文本。因此,将会创建单个链接,范围从相交的第一个链接开头开始,到相交的最后一个链接末尾为止。与此相反,如果在此情况下 extendToLinkBoundary 为 false,则当前部分选择的链接将会拆分为两个链接。
参数
href:String — 链接引用的 URI。
| |
targetString:String (default = null) — 链接的目标浏览器窗口。
| |
extendToLinkBoundary:Boolean (default = false) — 指定是否使用任何现有链接进行重叠来巩固选择,然后应用更改。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
LinkElement — 已创建的 LinkElement。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
public class EditManager_applyLink
{
static public function makeLink( selection:SelectionState ):void
{
var textFlow:TextFlow = selection.textFlow;
var editManager:IEditManager = textFlow.interactionManager as IEditManager;
editManager.applyLink( "http://www.adobe.com" );
}
static public function removeLink( selection:SelectionState ):void
{
var textFlow:TextFlow = selection.textFlow;
var editManager:IEditManager = textFlow.interactionManager as IEditManager;
editManager.applyLink( null, null, true );
}
}
}
applyParagraphFormat | () | 方法 |
public function applyParagraphFormat(paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
将段落样式应用于所选项目中的任何段落。
格式对象中所有 null 样式属性将不会改变。
参数
paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat — 要应用于所选段落的格式。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.TextAlign;
import flashx.textLayout.formats.TextLayoutFormat;
public class EditManager_applyParagraphFormat
{
static public 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 | () | 方法 |
public function applyTCY(tcyOn:Boolean, operationState:SelectionState = null):flashx.textLayout.elements:TCYElement| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10 - + 10.2, AIR 1.5 |
将文本转换为 TCY 串或将 TCY 串转换为非 TCY 文本。
日语文本中的 TCY(表示 tate-chuu-yoko)可使文本在一个垂直行内水平绘制,并用于提高非日文文本或数字(例如日期)的小文本块在垂直文本中的可读性。
参数
tcyOn:Boolean — 设置为 true 时会将 TCY 应用于文本范围,指定为 false 时会删除 TCY。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
flashx.textLayout.elements:TCYElement — 已创建的 TCYElement。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
public class EditManager_applyTCY
{
static public function tcyOn( selection:SelectionState ):void
{
var textFlow:TextFlow = selection.textFlow;
var editManager:IEditManager = textFlow.interactionManager as IEditManager;
editManager.applyTCY( true );
}
static public function tcyOff( selection:SelectionState ):void
{
var textFlow:TextFlow = selection.textFlow;
var editManager:IEditManager = textFlow.interactionManager as IEditManager;
editManager.applyTCY( false );
}
}
}
beginCompositeOperation | () | 方法 |
public function beginCompositeOperation():void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
开始一组新操作。
在调用 beginCompositeOperation() 之后及调用对应的 endCompositeOperation() 之前执行的所有操作,将作为单个操作执行和成组,该操作可作为一个单元撤消。
beginCompositeOperation/endCompositeOperation 块可以嵌入在其它 beginCompositeOperation/endCompositeOperation 块中。
示例 ( 如何使用本示例 )
beginCompositeOperation() 和 endCompositeOperation() 函数,则其中每个子操作将必须单独撤消而不是作为一个组撤消。
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
public class EditManager_beginCompositeOperation
{
static public 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 | () | 方法 |
public function changeElementID(newID:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
更改元素的 ID。
如果将 relativeStart 或 relativeEnd 参数设置为非默认值,则会拆分元素。位于该范围之外的元素部分将保留原始 ID。设置 relativeStart 和 relativeEnd 参数将使用重复的 ID 创建元素。
参数
newID:String — 新 ID 值。
| |
targetElement:FlowElement — 要修改的元素。
| |
relativeStart:int (default = 0) — 指定新 ID 时,距离拆分元素时所在的元素开头的偏移。
| |
relativeEnd:int (default = -1) — 指定新 ID 时,距离拆分元素时所在的元素开头的偏移。
| |
operationState:SelectionState (default = null) — 指定撤消此操作时要还原的当前选择;如果为 null,则该操作会保存当前选择。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.ElementRange;
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
public class EditManager_changeElementID
{
static public 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 | () | 方法 |
public function changeStyleName(newName:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
更改整个元素或部分元素的 styleName。
如果将 relativeStart 或 relativeEnd 参数设置为非默认值,则会拆分元素。位于该范围之外的元素部分将保留原始样式。
参数
newName:String — 新样式的名称。
| |
targetElement:FlowElement — 指定要更改的元素。
| |
relativeStart:int (default = 0) — 指定新样式时,距离拆分元素时所在的元素开头的偏移。
| |
relativeEnd:int (default = -1) — 指定新样式时,距离拆分元素时所在的元素末尾的偏移。
| |
operationState:SelectionState (default = null) — 指定撤消此操作时要还原的当前选择;如果为 null,则该操作会保存当前选择。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.ElementRange;
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
public class EditManager_changeStyleName
{
static public 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 );
}
}
}
changeTypeName | () | 方法 |
public function changeTypeName(newName:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
更改整个元素或部分元素的 typeName。
如果将 relativeStart 或 relativeEnd 参数设置为非默认值,则会拆分元素。位于该范围之外的元素部分将保留原始样式。
参数
newName:String — 新类型的名称。
| |
targetElement:FlowElement — 指定要更改的元素。
| |
relativeStart:int (default = 0) — 指定新样式时,距离拆分元素时所在的元素开头的偏移
| |
relativeEnd:int (default = -1) — 指定新样式时,距离拆分元素时所在的元素末尾的偏移
| |
operationState:SelectionState (default = null) — 指定撤消此操作时要还原的当前选择;如果为 null,则该操作会保存当前选择。
|
clearFormat | () | 方法 |
public function clearFormat(leafFormat:flashx.textLayout.formats:ITextLayoutFormat, paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat, containerFormat:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
对指定(或当前)所选项目的格式取消定义。
执行一个不可撤消的操作,该操作对指定格式取消定义。只应用为 TextLayoutFormat 对象设置的样式属性。格式对象中的未定义属性没有改变。
参数
leafFormat:flashx.textLayout.formats:ITextLayoutFormat — 一种格式,其设置值指示用于取消定义选定范围中 LeafFlowElement 对象的属性。
| |
paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat — 其设置的值指示对所选范围内的 ParagraphElement 对象取消定义的属性的格式。
| |
containerFormat:flashx.textLayout.formats:ITextLayoutFormat — 其设置的值指示对所选范围内的 ContainerController 对象取消定义的属性的格式。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
clearFormatOnElement | () | 方法 |
public function clearFormatOnElement(targetElement:FlowElement, format:flashx.textLayout.formats:ITextLayoutFormat, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
对指定元素的样式取消定义。
格式对象中所有 undefined 的样式属性将保持不变。在指定的格式中定义的任何样式都未在指定的元素上定义。
参数
targetElement:FlowElement — 将应用样式的元素。
| |
format:flashx.textLayout.formats:ITextLayoutFormat — 包含要取消定义的样式的格式。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
createDiv | () | 方法 |
public function createDiv(parent:FlowGroupElement = null, format:flashx.textLayout.formats:ITextLayoutFormat = null, operationState:SelectionState = null):DivElement在同时包含范围的开始和结束点的最低公共父元素位置,创建包含在 operationState 中指定的整个范围的新 DivElement。如果开始和结束点是相同的,则会在此位置使用单个子段落创建新的 DivElement。
参数
parent:FlowGroupElement (default = null) — 为新的 DivElement 指定父代元素。如果为 null,则新的父代是包含 SelectionState 的最低级别。
| |
format:flashx.textLayout.formats:ITextLayoutFormat (default = null) — 应用于新 DivElement 的格式属性。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
DivElement — 已创建的新 DivElement.
|
createList | () | 方法 |
public function createList(parent:FlowGroupElement = null, format:flashx.textLayout.formats:ITextLayoutFormat = null, operationState:SelectionState = null):ListElement在同时包含范围的开始和结束点的最低公共父元素位置,创建包含在 operationState 中指定的整个范围的新 ListElement。范围中的每个段落会成为新 ListElement 中的 ListItemElement。如果开始和结束点是相同的,则会在此位置使用单个 ListItemElement 子代创建新 ListElement。
参数
parent:FlowGroupElement (default = null) — 为新的 ListElement 指定父代元素(可选)。如果为 null,则新的父代是包含 SelectionState 的最低级别。
| |
format:flashx.textLayout.formats:ITextLayoutFormat (default = null) — 应用于新 ListElement 的格式属性。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
ListElement — 已创建的新 ListElement.
|
createSubParagraphGroup | () | 方法 |
public function createSubParagraphGroup(parent:FlowGroupElement = null, format:flashx.textLayout.formats:ITextLayoutFormat = null, operationState:SelectionState = null):SubParagraphGroupElement在同时包含范围的开始和结束点的最低公共父元素位置,创建包含在 operationState 中指定的整个范围的新 SubParagraphGroupElement。如果开始和结束点相同,则无操作。
参数
parent:FlowGroupElement (default = null) — 为新的 SubParagraphGroupElement 元素指定父代元素。如果为 null,则新的父代是包含 SelectionState 的最低级别。
| |
format:flashx.textLayout.formats:ITextLayoutFormat (default = null) — 应用于新 SubParagraphGroupElement 的格式属性
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
SubParagraphGroupElement — 已创建的新 SubParagraphGroupElement.
|
cutTextScrap | () | 方法 |
public function cutTextScrap(operationState:SelectionState = null):flashx.textLayout.edit:TextScrap| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
删除选择的区域并在 TextScrap 对象中返回删除的区域。
生成的 TextScrap 可以发布到系统剪贴板或用于后续的 pasteTextOperation() 操作中。
参数
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
flashx.textLayout.edit:TextScrap — 剪切的 TextScrap。
|
相关 API 元素
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.edit.TextScrap;
import flashx.undo.UndoManager;
import flashx.textLayout.elements.TextFlow;
public class EditManager_cutTextScrap
{
static public function cutTextScrap():TextScrap
{
var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
var editManager:EditManager = new EditManager( new UndoManager() );
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 4, 7 );
var scrap:TextScrap = editManager.cutTextScrap(); //Displays: How now brown cow.
return scrap;
}
}
}
deleteNextCharacter | () | 方法 |
public function deleteNextCharacter(operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
删除某一范围内的文本,或者,如果进行了点选择,则删除下一个字符。
参数
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
public class EditManager_deleteNextCharacter
{
static public function deleteNextCharacter():void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown crow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
var editManager:EditManager = new EditManager();
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 15, 15 );
editManager.deleteNextCharacter(); //displays: How now brown cow.
}
}
}
deleteNextWord | () | 方法 |
public function deleteNextWord(operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
删除下一个字。
如果选择了一个范围,则会删除该范围内的第一个字。
参数
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
public class EditManager_deleteNextWord
{
static public function deleteNextWord():void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
var editManager:EditManager = new EditManager();
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 3, 3 );
editManager.deleteNextWord(); //displays: How now brown cow.
}
}
}
deletePreviousCharacter | () | 方法 |
public function deletePreviousCharacter(operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
删除某一范围内的文本,或者,如果进行了点选择,则删除上一个字符。
参数
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
public class EditManager_deletePreviousCharacter
{
static public function deletePreviousCharacter():void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown crow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
var editManager:EditManager = new EditManager();
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 16, 16 );
editManager.deletePreviousCharacter(); //displays: How now brown cow.
}
}
}
deletePreviousWord | () | 方法 |
public function deletePreviousWord(operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
删除上一个字。
如果选择了一个范围,则会删除该范围内的第一个字。
参数
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
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 | () | 方法 |
public function deleteText(operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
删除某一范围内的文本。
参数
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
public class EditManager_deleteText
{
static public function deleteText():void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
var editManager:EditManager = new EditManager();
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 4, 7 );
editManager.deleteText(); //displays: How now brown cow.
}
}
}
doOperation | () | 方法 |
override public function doOperation(operation:FlowOperation):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
执行 FlowOperation。
doOperation() 方法由更新文本流的 IEditManager 函数调用。您通常不需要直接调用该函数,除非要创建自定义操作。
该函数继续执行下列步骤:
- 在执行该操作之前刷新任何挂起的操作。
- 发送可取消的 flowOperationBegin 事件。如果取消,则该方法立即返回。
- 执行该操作。该操作返回
true或false。False表明没有进行任何更改。 - 将操作推入到撤消堆栈中。
- 清除重做堆栈。
- 更新显示。
- 发送可取消的 flowOperationEnd 事件。
异常处理:如果该操作引发异常,则会被捕获,而错误将附加到 flowOperationEnd 事件。如果未取消该错误,将会重新引发错误。
参数
operation:FlowOperation — FlowOperation 对象
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.operations.InsertTextOperation;
public class EditManager_doOperation
{
static public function doOperation(sprite:Sprite):void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( sprite ));
var editManager:EditManager = new EditManager();
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
var selectionState:SelectionState = new SelectionState(textFlow, 4, 4);
var insertOperation:InsertTextOperation = new InsertTextOperation( selectionState, "now " );
editManager.doOperation( insertOperation ); // displays: How now brown cow
}
}
}
endCompositeOperation | () | 方法 |
public function endCompositeOperation():void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
结束一组操作。
自上一个 beginCompositeOperation() 调用后执行的所有操作将组成为一个 CompositeOperation,然后完成该复合操作。该 CompositeOperation 对象会添加到撤消堆栈中,或者,如果该复合操作嵌入在其它复合操作中,则会添加到该父操作。
示例 ( 如何使用本示例 )
beginCompositeOperation() 和 endCompositeOperation() 函数,则其中每个子操作将必须单独撤消而不是作为一个组撤消。
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.TextFlow;
public class EditManager_beginCompositeOperation
{
static public 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 | () | 方法 |
public function insertInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):InlineGraphicElement| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10 - + 10.2, AIR 1.5 |
插入图像。
图像的源可以是包含 URI 的字符串、URLRequest 对象、表示嵌入资源的 Class 对象或 DisplayObject 实例。
宽度和高度值可以是像素数、百分比或字符串“auto”,在此情况下将使用图形的实际尺寸。
将 float 设置为 Float 类中定义的一个常量,以指定图像应显示在任何文本的左侧或右侧还是嵌入在文本中。
参数
source:Object — 可以是解释为 URI 的 String、解释为 Embed DisplayObject 类的 Class、DisplayObject 实例或 URLRequest。
| |
width:Object — 要插入的图像的宽度(数字、百分比或“auto”)。
| |
height:Object — 要插入的图像的高度(数字、百分比或“auto”)。
| |
options:Object (default = null) — 全不支持.
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
InlineGraphicElement |
相关 API 元素
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Shape;
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
public class EditManager_insertInlineGraphic
{
static public function insertInlineGraphic(sprite:Sprite):void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( sprite ));
var editManager:EditManager = new EditManager( new UndoManager() );
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 0, 0 );
editManager.insertInlineGraphic( createGraphic(), 6, 6, "none" );
}
static private function createGraphic():Shape
{
var shape:Shape = new Shape();
shape.graphics.beginFill( 0x993366 );
shape.graphics.drawCircle( 5, 4, 6 );
return shape;
}
}
}
insertText | () | 方法 |
public function insertText(text:String, origOperationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
插入文本。
在文本中某一位置或范围内插入文本。如果 operationState 参数提供的位置是一个范围(或者该参数为 null 而当前选择内容是一个范围),则当前位于该范围内的文本将被插入的文本替换。
参数
text:String — 要插入的字符串。
| |
origOperationState:SelectionState (default = null) — 指定该操作所作用的流中文本;如果为 null,则该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
public class EditManager_insertText
{
static public function insertText(sprite:Sprite):void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( sprite ));
var editManager:EditManager = new EditManager( new UndoManager() );
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 4, 4 );
editManager.insertText( "now " );
}
}
}
modifyInlineGraphic | () | 方法 |
public function modifyInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
修改现有内嵌图形。
将无变化的属性设置为原始图形中的值。(修改现有图形对象通常比删除并重新创建一个图形对象效率更高。)
参数
source:Object — 可以是解释为 URI 的 String、解释为 Embed DisplayObject 类的 Class、DisplayObject 实例或 URLRequest。
| |
width:Object — 图像的新宽度(数字或百分比)。
| |
height:Object — 图像的新高度(数字或百分比)。
| |
options:Object (default = null) — 全不支持.
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
width 和 height 属性以将其拉伸为一个椭圆:
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flash.display.Shape;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
public class EditManager_modifyInlineGraphic
{
static public function modifyInlineGraphic(sprite:Sprite):void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( sprite ));
var editManager:EditManager = new EditManager( new UndoManager() );
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 0, 0 );
editManager.insertInlineGraphic( createGraphic(), 6, 6, "none" );
editManager.selectRange( 0, 1 );
editManager.modifyInlineGraphic( null, '12', '5', 'none' );
}
static private function createGraphic():Shape
{
var shape:Shape = new Shape();
shape.graphics.beginFill( 0x993366 );
shape.graphics.drawCircle( 4, 4, 6 );
return shape;
}
}
}
moveChildren | () | 方法 |
public function moveChildren(source:FlowGroupElement, sourceIndex:int, numChildren:int, destination:FlowGroupElement, destinationIndex:int, selectionState:SelectionState = null):void将一组 FlowElement 从一个 FlowGroupElement 移动至另一个 FlowGroupElement。目标属性必须是正在移动的子代的合法父代类型,否则会引发异常。
参数
source:FlowGroupElement — 要移动的元素的原始父代。
| |
sourceIndex:int — 要移动的第一个元素的源中的子索引。
| |
numChildren:int — 要移动的子元素数。
| |
destination:FlowGroupElement — 移动后元素的新父代。
| |
destinationIndex:int — 要将元素移动到的目标中的子索引。
| |
selectionState:SelectionState (default = null) — 指定该操作所应用的文本,以及指定撤消时选择内容返回到的文本。如果为 null,则操作应用于当前选择内容。如果没有当前选区,则该参数必须为非 null。
|
overwriteText | () | 方法 |
public function overwriteText(text:String, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
覆盖所选文本。
如果进行了点选择,则新文本将覆盖第一个字符。
参数
text:String — 要插入的字符串。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
public class EditManager_overwriteText
{
static public function overwriteText(sprite:Sprite):void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How zzz brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( sprite ));
var editManager:EditManager = new EditManager( new UndoManager() );
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 4, 6 );
editManager.overwriteText( "now" ); //Displays: How now brown cow.
}
}
}
pasteTextScrap | () | 方法 |
public function pasteTextScrap(scrapToPaste:flashx.textLayout.edit:TextScrap, operationState:SelectionState = null):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
将 TextScrap 粘贴到选定区域。
如果指定了文本范围,则会删除该范围内的文本。
参数
scrapToPaste:flashx.textLayout.edit:TextScrap — 要粘贴的 TextScrap。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
相关 API 元素
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.edit.TextScrap;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
public class EditManager_pasteTextScrap
{
static public function pasteText(sprite:Sprite):void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow now.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( sprite ));
var editManager:EditManager = new EditManager( new UndoManager() );
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 13, 17 );
var scrap:TextScrap = editManager.cutTextScrap();
editManager.selectRange( 3, 3 );
editManager.pasteTextScrap( scrap ); //Displays: How now brown cow.
}
}
}
redo | () | 方法 |
public function redo():void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
执行上一个撤消的操作。
注意:如果与该 IEditManager 关联的 IUndoManager 也与其它 IEditManager 相关联,则有可能与后一个 IEditManager 关联的重做操作就是重做的操作。如果其它 IEditManager 的 FlowOperation 位于重做堆栈顶端,则可能发生这种情况。
如果未启用撤消功能,则该函数不执行任何操作。
相关 API 元素
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.elements.TextFlow;
public class EditManager_redo
{
static public function redo( textFlow:TextFlow ):void
{
if( textFlow.interactionManager is IEditManager )
{
IEditManager( textFlow.interactionManager ).redo();
}
}
}
}
splitElement | () | 方法 |
public function splitElement(target:FlowGroupElement, operationState:SelectionState = null):FlowGroupElement在指定位置拆分目标元素,同时在当前元素后创建新元素。如果 operationState 是一个范围,则会删除范围中的文本。在 operationState 指定的文本位置后创建新元素。请注意,拆分 SubParagraphGroupElement 将会无效果,因为它们会自动与相邻元素重新合并。
您可能要使用的示例就是,如果您有一个列表,并且希望将其分为两个列表。
参数
target:FlowGroupElement — 要拆分的元素。
| |
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
FlowGroupElement — 已创建的新段落。
|
splitParagraph | () | 方法 |
public function splitParagraph(operationState:SelectionState = null):ParagraphElement| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
在当前位置拆分段落,同时在当前段落后创建新段落。
如果指定了文本范围,则会删除该范围内的文本。
参数
operationState:SelectionState (default = null) — 指定该操作所作用的文本;如果为 null,该操作将应用于当前选择内容。
|
ParagraphElement — 已创建的新段落。
|
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.edit.TextScrap;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
public class EditManager_splitParagraph
{
static public function splitParagraph(sprite:Sprite):void
{
var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer.addController( new ContainerController( sprite ));
var editManager:EditManager = new EditManager( new UndoManager() );
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();
editManager.selectRange( 8, 8 );
editManager.splitParagraph(); //Displays: How now
// brown cow.
}
}
}
undo | () | 方法 |
public function undo():void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
恢复上一个操作。
注意:如果与该 IEditManager 关联的 IUndoManager 也与其它 IEditManager 相关联,则有可能与后一个 IEditManager 关联的撤消操作就是撤消的操作。如果其它 IEditManager 的 FlowOperation 位于撤消堆栈顶端,则可能会发生这种情况。
如果未启用撤消功能,则该函数不执行任何操作。
相关 API 元素
示例 ( 如何使用本示例 )
package flashx.textLayout.edit.examples
{
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.elements.TextFlow;
public class EditManager_undo
{
static public function undo( textFlow:TextFlow ):void
{
if( textFlow.interactionManager is IEditManager )
{
IEditManager( textFlow.interactionManager ).undo();
}
}
}
}
updateAllControllers | () | 方法 |
public function updateAllControllers():void- 创建 TextFlow (
tf) 以包含示例文本行。 - 将文本存储在 SpanElement 中,而 SpanElement 又存储在 ParagraphElement 中。
- 为文本创建 ContainerController 并合成文本以便显示。
- 实例化 TextFlow 管理器对象以供将来由事件侦听器使用。
- 创建非常简单的编辑按钮,通过该按钮,用户可以使文本可编辑。
- 创建按钮的事件侦听器,用于在只读状态和可编辑状态之间切换。
TextFlow 的 interactionManager 属性值确定示例文本是否可编辑。如果属性为 null,则示例文本为只读。如果为属性指定 EditManager 实例,则示例文本可编辑。createEditButton() 方法创建与非常简单的按钮类似的 TextField 实例。用户单击 TextField 实例时,updateEditable() 侦听器函数将切换 interactionManager 属性的值。
package flashx.textLayout.edit.examples {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import flashx.undo.UndoManager;
public class EditManager_example extends Sprite
{
private var tf:TextFlow;
private var em:EditManager;
private var um:UndoManager;
private var editable:TextField;
public function EditManager_example()
{
//define TextFlow
tf = new TextFlow();
//define elements to contain text
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);
tf.addChild(p);
//compose TextFlow to display
var tfController:ContainerController = new ContainerController(this,600,600);
tfController.container.y = 10
tf.flowComposer.addController(tfController);
tf.flowComposer.updateAllControllers();
//define TextFlow manager objects
um = new UndoManager();
em = new EditManager(um);
tf.interactionManager = null;
createEditButton();
}
private function createEditButton ():void {
editable = new TextField();
editable.appendText("Click to make the sample text editable");
editable.x = 0;
editable.y = 50;
editable.width = 150;
editable.autoSize = flash.text.TextFieldAutoSize.LEFT;
editable.selectable = false;
editable.background = true;
editable.backgroundColor = 0xAAAAAA;
addChild(editable);
editable.addEventListener(MouseEvent.CLICK, updateEditable);
}
private function updateEditable(me:MouseEvent):void{
if (editable.text.indexOf("read only") >= 0) {
editable.text = "Click to make the sample text editable";
tf.interactionManager = null;
}
else {
editable.text = "Click to make the sample text read only";
tf.interactionManager = em;
}
}
}
}
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性