Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had this exact same issue, and it's had me flummoxed for a while. Here's what I did to get the desired behaviour:</p> <p><strong>1)</strong> Instead of using a listener for TextEvent.LINK, listen for MouseEvent.CLICK (or TouchEvent.TAP) on the TextField.</p> <p>eg.</p> <pre><code>var tf:TextField = new TextField(); tf.addEventListener(MouseEvent.CLICK, linkClicked); </code></pre> <p><strong>2)</strong> In the linkClicked() handler, you use getCharIndexAtPoint() to determine the index of the character that was clicked, and then from that determine the URL from the TextFormat of the character. This is adapted from a post by Colin Holgate on the Adobe Forums (<a href="http://forums.adobe.com/thread/231754" rel="nofollow">http://forums.adobe.com/thread/231754</a>)</p> <pre><code>public function linkClicked(e:MouseEvent):void { var idx:int = e.target.getCharIndexAtPoint(e.localX, e.localY); trace("Tapped:",idx); var tf:TextFormat = e.target.getTextFormat(idx); if(tf.url != "" &amp;&amp; tf.url != null) { var linkURL:String = tf.url; trace(linkURL); // Hyperlink processing code here dispatchEvent(new UIEvent(UIEvent.LINK_TAPPED,tf.url)); } } </code></pre> <p>3) The last line (dispatchEvent()) is sending a custom event to another function to process the link, but you could easily inline your code here.</p> <p>I've tested on an iPad 3 running iOS6.1, building with AIR3.5. Links are much more responsive, and I don't find myself mashing the screen trying to hit the stroke of the text!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload