flash.text.engine

# TextLineMirrorRegion - AS3

Package | flash.text.engine
Class | public final class TextLineMirrorRegion
Inheritance | TextLineMirrorRegion Object

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The TextLineMirrorRegion class represents a portion of a text line wherein events are mirrored to another event dispatcher.

After normal event-dispatching for a text line finishes, if the line is valid and event propagation has not been stopped, events are re dispatched to the mirror regions of the line.

Mirroring of mouse events is a special case. Because mirror regions aren't actually display objects, `mouseOver` and `mouseOut` events are simulated for them. The `rollOver` and `rollOut` events are not simulated. All naturally occuring `mouseOver`, `mouseOut`, `rollOver` and `rollOut` events (whether targetted at the text line or at children of the text line) are ignored - they are not mirrored.

You cannot create a TextLineMirrorRegion object directly from ActionScript code. If you call `new TextLineMirrorRegion()`, an exception is thrown. A TextLineMirrorRegion is created and associated with a text line when that text line is created from a ContentElement object with an event mirror set.

The TextLineMirrorRegion class is final; it cannot be subclassed.

View the examples

Related API Elements

ContentElement.eventMirror
TextBlock.createTextLine()
TextLine.mirrorRegions

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | bounds : Rectangle [read-only] The bounds of the mirror region, relative to the text line. | TextLineMirrorRegion
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | element : ContentElement [read-only] The ContentElement object from which the mirror region was derived. | TextLineMirrorRegion
|  | mirror : EventDispatcher [read-only] The EventDispatcher object to which events affecting the mirror region are mirrored. | TextLineMirrorRegion
|  | nextRegion : flash.text.engine:TextLineMirrorRegion [read-only] The next TextLineMirrorRegion in the set derived from the text element, or null if the current region is the last mirror region in the set. | TextLineMirrorRegion
|  | previousRegion : flash.text.engine:TextLineMirrorRegion [read-only] The previous TextLineMirrorRegion in the set derived from the text element, or null if the current region is the first mirror region in the set. | TextLineMirrorRegion
|  | textLine : flash.text.engine:TextLine [read-only] The TextLine containing this mirror region. | TextLineMirrorRegion

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

### bounds

property

`bounds:Rectangle` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The bounds of the mirror region, relative to the text line.

Implementation
`public function get bounds():Rectangle`

### element

property

`element:ContentElement` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The `ContentElement` object from which the mirror region was derived.

Implementation
`public function get element():ContentElement`
Throws

| `IllegalOperationError` — The TextLine to which this element belongs is not valid.

### mirror

property

`mirror:EventDispatcher` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The `EventDispatcher` object to which events affecting the mirror region are mirrored. This includes mouse events that specifically occur in the mirror region, and all other events that target the text line.

Implementation
`public function get mirror():EventDispatcher`

### nextRegion

property

`nextRegion:flash.text.engine:TextLineMirrorRegion` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The next TextLineMirrorRegion in the set derived from the text element, or `null` if the current region is the last mirror region in the set. May be on the same line or on another text line.

Implementation
`public function get nextRegion():flash.text.engine:TextLineMirrorRegion`

### previousRegion

property

`previousRegion:flash.text.engine:TextLineMirrorRegion` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The previous TextLineMirrorRegion in the set derived from the text element, or `null` if the current region is the first mirror region in the set. May be on the same line or on another text line.

Implementation
`public function get previousRegion():flash.text.engine:TextLineMirrorRegion`

### textLine

property

`textLine:flash.text.engine:TextLine` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4

The TextLine containing this mirror region.

Implementation
`public function get textLine():flash.text.engine:TextLine`
Examples How to use this example
TextLineMirrorRegionExample.as
This example displays a block of text with mirror regions that turn red when you click them.
Copy

    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);
                }
            }
        }
    }

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00