| 套件 | 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, 03:47 PM Z
隱藏繼承公用屬性
顯示繼承公用屬性