Skip to main content
September 28, 2009
Question

Handling custom mouse interaction/inserting unique links

  • September 28, 2009
  • 1 reply
  • 517 views

HI All,

I would like to insert links to the text, but not the html formatted one.

I would like to add a handler function to the link and when the link is pressed the function could do whatever it is needed. It would be great if the link could have an invisible object or a value in order to keep some extra information.

I hope there is a solution.

Benjamin

This topic has been closed for replies.

1 reply

Adobe Employee
September 28, 2009

Get the examples in the Download section here: http://opensource.adobe.com/wiki/display/tlf/Text+Layout+Framework

Look for the CustomLinkEvent.as file.  That does exactly what you want.

You can add any information you want to any FlowElement with the setStyle method.  For example: linkElement.setStyle("foo","bar");

Richard

September 28, 2009

Unortunately the link does not work.

I came up with my solution.

We can handle the link clicks like here:

_flow.addEventListener(FlowElementMouseEvent.CLICK, onFlowClick);
_flow.addEventListener(FlowElementMouseEvent.ROLL_OVER, onFlowOver);
_flow.addEventListener(FlowElementMouseEvent.ROLL_OUT, onFlowOut);

then we know the LinkElement:

        private function onFlowClick(ev:FlowElementMouseEvent):void {
           
            var element:LinkElement = ev.flowElement as LinkElement;
   
            ev.stopImmediatePropagation();
            ev.preventDefault();

            trace(element.href);
           
        }

and href can be like a JSON object ( I know it would be terrible in terms of performance ) or a simple string reference to somewhere, but now with your answer it is clear - I can save anything into LinkElement in the meantime when I do applyLink with setStyle.

then just read element["foo"] right?