If you move your mouse pointer over a hyperlink in an HTML webpage, your browser typically displays the URL in it’s status bar. In addition, if the hyperlink has a title
attribute set, a tooltip is shown with a human readable description of the linked resource.
Unfortunately, with rich text used in Flash websites/applications this is not the case. Your mouse pointer will change to a “hand-cursor”, indicating you’re hovering a hyperlink, but the status bar will stay empty, and the title attribute is ignored by Flash, making it impossible for you to find out where the hyperlink will take you without actually clicking it.
With Flash Player 8.5 alpha, the behaviour of hyperlinks in rich text controls hasn’t changed (yet?), but luckily Macromedia implemented some nifty API extensions making it possible to actually find out if the user is hovering a hyperlink in a HTML enabled TextField.
Here’s how it works:
FP 8.5 introduces the TextField.getCharIndexAtPoint(x, y)
method, returning the index of the character in a TextField at the point (x, y).
You can then get the TextFormat of the character at that index, using TextField.getTextFormat(i, i+1)
, and check it’s url
property. If set, display it in a Tooltip, or send it to Javascript via ExternalInterface to show it in the browser’s status bar. Done.
Demo:
http://codeazur.com.br/stuff/flex2/OnHoverApp.html (FP 8.5 required)
http://codeazur.com.br/stuff/flex2/OnHoverApp.zip (Sources)
In this demo i subclassed the Flex 2 component mx.controls.Text
and use it via MXML, however you can as well use this method with normal TextFields in your Actionscript 3 projects.
cooooool – that’s sexy!
Very cool!
Any interest in adding keyboard and screenreader support to those links?
http://www.majordan.net/test/flashlinks/
I’ll give it a try when I get a free moment.
Cool! Yeah we should definately merge that
What should i do to display the title attribute to inside flash