| 包 | flash.text.engine |
| 类 | public final class TextLineMirrorRegion |
| 继承 | TextLineMirrorRegion Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5, Flash Lite 4 |
在针对文本行的正常事件调度完成后,如果该文本行有效并且事件传播尚未终止,则事件将重新调度到行的镜像区域。
镜像鼠标事件是一个特例。由于镜像区域并不实际显示对象,因此将为这些区域模拟 mouseOver 和 mouseOut 事件。并不模拟 rollOver 和 rollOut 事件。忽略所有自然发生的 mouseOver、mouseOut、rollOver 和 rollOut 事件(无论这些事件将文本行作为目标还是将文本行的子项作为目标),不会镜像它们。
无法从 ActionScript 代码直接创建 TextLineMirrorRegion 对象。如果调用 new TextLineMirrorRegion(),则会引发异常。通过事件镜像集从 ContentElement 对象创建文本行时,创建 TextLineMirrorRegion 并与该文本行关联。
TextLineMirrorRegion 类是最终类;无法从其派生子类。
相关 API 元素
| 属性 | 由以下参数定义 | ||
|---|---|---|---|
| bounds : Rectangle [只读]
相对文本行的镜像区域范围。 | TextLineMirrorRegion | ||
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
| element : ContentElement [只读]
从中派生该镜像区域的 ContentElement 对象。 | TextLineMirrorRegion | ||
| mirror : EventDispatcher [只读]
向其镜像影响镜像区域的事件的 EventDispatcher 对象。 | TextLineMirrorRegion | ||
| nextRegion : flash.text.engine:TextLineMirrorRegion [只读]
集合中从文本元素派生的下一个 TextLineMirrorRegion,如果当前区域是集合中的最后一个镜像区域,则为 null。 | TextLineMirrorRegion | ||
| previousRegion : flash.text.engine:TextLineMirrorRegion [只读]
集合中从文本元素派生的上一个 TextLineMirrorRegion,如果当前区域是集合中的第一个镜像区域,则为 null。 | TextLineMirrorRegion | ||
| textLine : flash.text.engine:TextLine [只读]
包含此镜像区域的 TextLine。 | TextLineMirrorRegion | ||
bounds | 属性 |
element | 属性 |
element:ContentElement [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5, Flash Lite 4 |
从中派生该镜像区域的 ContentElement 对象。
实现
public function get element():ContentElement引发
IllegalOperationError — 此元素所属的 TextLine 无效。
|
mirror | 属性 |
mirror:EventDispatcher [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5, Flash Lite 4 |
向其镜像影响镜像区域的事件的 EventDispatcher 对象。这包括专门在镜像区域中发生的鼠标事件和将文本行作为目标的所有其他事件。
实现
public function get mirror():EventDispatchernextRegion | 属性 |
nextRegion:flash.text.engine:TextLineMirrorRegion [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5, Flash Lite 4 |
集合中从文本元素派生的下一个 TextLineMirrorRegion,如果当前区域是集合中的最后一个镜像区域,则为 null。可以在同一行上,也可以在其他文本行上。
实现
public function get nextRegion():flash.text.engine:TextLineMirrorRegionpreviousRegion | 属性 |
previousRegion:flash.text.engine:TextLineMirrorRegion [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5, Flash Lite 4 |
集合中从文本元素派生的上一个 TextLineMirrorRegion,如果当前区域是集合中的第一个镜像区域,则为 null。可以在同一行上,也可以在其他文本行上。
实现
public function get previousRegion():flash.text.engine:TextLineMirrorRegiontextLine | 属性 |
textLine:flash.text.engine:TextLine [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5, Flash Lite 4 |
包含此镜像区域的 TextLine。
实现
public function get textLine():flash.text.engine:TextLine
package {
import flash.display.Sprite;
import flash.text.engine.TextBlock;
import flash.text.engine.TextLine;
import flash.text.engine.TextElement;
import flash.text.engine.ElementFormat;
import flash.text.engine.FontDescription;
import flash.text.engine.ContentElement;
import flash.text.engine.GroupElement;
import flash.text.engine.TextLineMirrorRegion;
import flash.events.MouseEvent;
import flash.events.EventDispatcher;
import flash.ui.Mouse;
public class TextLineMirrorRegionExample extends Sprite {
var myEvent:EventDispatcher = new EventDispatcher();
var fontDescription:FontDescription = new FontDescription();
var textBlock:TextBlock = new TextBlock();
public function TextLineMirrorRegionExample():void {
fontDescription.fontWeight = "bold";
var blackFormat:ElementFormat = new ElementFormat();
blackFormat.fontSize = 18;
blackFormat.color = 0x000000;
blackFormat.fontDescription = fontDescription;
var textElement1 = new TextElement("Click on different parts of me to find the ", blackFormat);
var textElement2 = new TextElement("mirror regions",blackFormat);
var textElement3 = new TextElement(". If I am a mirror region, I'll ",blackFormat);
var textElement4 = new TextElement("turn red",blackFormat);
var textElement5 = new TextElement(".",blackFormat);
myEvent.addEventListener("click", clickHandler);
myEvent.addEventListener("mouseOut", mouseOutHandler);
myEvent.addEventListener("mouseOver", mouseOverHandler);
var groupVector:Vector.<ContentElement> = new Vector.<ContentElement>;
groupVector.push(textElement1, textElement2, textElement3, textElement4, textElement5);
var groupElement:GroupElement = new GroupElement(groupVector);
textElement2.eventMirror=myEvent;
textElement4.eventMirror=myEvent;
textBlock.content = groupElement;
createLines(textBlock);
}
private function clickHandler(event:MouseEvent):void
{
var redFormat:ElementFormat = new ElementFormat();
redFormat.color = 0xCC0000;
redFormat.fontSize = 18;
redFormat.fontDescription = fontDescription;
var line:TextLine = event.target as TextLine;
var region:TextLineMirrorRegion = line.getMirrorRegion(myEvent);
region.element.elementFormat = redFormat;
createLines(textBlock);
}
private function mouseOverHandler(event:MouseEvent):void
{
Mouse.cursor = "button";
}
private function mouseOutHandler(event:MouseEvent):void
{
Mouse.cursor = "arrow";
}
private function createLines(textBlock:TextBlock):void
{
var purgeLine:TextLine = textBlock.firstLine;
while (purgeLine)
{
removeChild (purgeLine);
purgeLine = purgeLine.nextLine;
}
var lineWidth:Number = 150;
var xPos:Number = 15.0;
var yPos:Number = 20.0;
var textLine:TextLine = textBlock.createTextLine (null, lineWidth);
while (textLine)
{
textLine.x = xPos;
textLine.y = yPos;
yPos += textLine.height + 2;
addChild (textLine);
textLine = textBlock.createTextLine (textLine, lineWidth);
}
}
}
}
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性