TLF FlowElement LinkElement Events and EventMirrors

Examples are posted here:


TLF includes support for LinkElements. A LinkElement similar to an html <a> element can have a URL and respond to hover events and click events. The URL is invoked on click. The rendering of the LinkElement will change if a linkHoverFormat or linkActiveFormat is specified. This markup will turn the link red on hover and green on click:

<TextFlow version="2.0.0" xmlns="">
<p><a href="">
<linkActiveFormat><TextLayoutFormat color="0xff00"/></linkActiveFormat>
<linkHoverFormat><TextLayoutFormat color="0xff0000"/></linkHoverFormat>

LinkElements and event: syntax

LinkElements can also be used to generate events on the click that a client can intercept. This is done by specifying the LinkElement.href property as "event:eventName". Client code can then attach a listener to the textFlow for eventName.

In the examples zip demonstrates changing the color of the text when a link is clicked.

Note that if an EditManager is attached to the textFlow then LinkElements only respond if the CTRL key (on windows) or Command key (on Mac) is pressed.


Several TLF elements also support event mirrors. This allows a client to attach listeners directly to FlowElements for various events defined in the FlowElementMouseEvent class. These events events are generated by TLF by observing the MouseEvents that occur over the TextLines and mapped to the FlowElements. The events that can be listened for are defined in FlowElementMouseEvent. These events are: MOUSE_DOWN, MOUSE_UP, ROLL_OVER, ROLL_OUT and CLICK. Listeners are attached by calling getEventMirror on a FlowElement with support. getEventMirror returns an IEventDispatcher on which the listener can be attached. Only the following FlowElements support getEventMirror: LinkElement, TCYElement, SubParagraphGroupElement, SpanElement and InlineGraphicElement.

In the examples zip file demonstrates the use of event mirrors.

Note that getEventMirror is a tlf_internal function. Event mirror support is still experimental in TLF 2.0 though there are no known bugs with dispatching events. Less well tested is how event mirrors withstand editing operations as well as cut, copy and paste. Copy, for example will not have event mirrors on the new copy. Splitting a FlowElement will only preserve the mirrors on one of the elements. Unlike the event: syntax on LinkElements event mirrors are not imported and exported in XML.

For various reasons TLF does not use FTE eventMirrors. The main one is that an eventual goal of TLF is to permit data binding to a TextFlow so that a single TextFlow can be displayed in multiple views. This event mirror architecture is a necessary step in that direction.

3 Responses to TLF FlowElement LinkElement Events and EventMirrors

  1. David Salahi says:

    Not sure how the LinkElements snippet is intended to be used as it’s not valid MXML. Here it is turned into valid MXML but it still doesn’t function correctly. Doesn’t work as a link; doesn’t change appearance on hover:



  2. David Salahi says:

    Oh, I see this page eats MXML tags. Not very helpful for having a discussion about this.

  3. Alan Stearns says:

    Not sure what to do about the comments leaving out markup – I tried to see if I could recover your code, but all I see is whitespace.

    The markup above is not MXML – it’s our TLF markup that you can import using our converters. It’s relatively simple to turn it into MXML by substituting the Flex component’s content tag for our TextFlow tag and adding whatever prefixes are necessary.

    The reason you aren’t seeing the hover change is that the text is read-write. In editing mode the link formatting and actions only apply if you have the command/control key held down (see the line with “EditManager” above)