I just spent an embarrassing amount of time trying to figure out why in the world the TextEvent.LINK event wasn’t being fired from a properly formatted anchor tag in my text field. It turns out that the text field must be selectable!
If the field is HTML-enabled and it contains something like this:
display_txt.htmlText = "<a href='event:ouch'>Click ME</a>";
You should be able to capture the click event like this:display_txt.addEventListener(TextEvent.LINK, clickHandler)
If the field is selectable then this works. If not selectable, then the hand cursor still shows up, but no event occurs.
I spent a little time this morning looking at the same issue, but the documentation does clearly state that it must be marked as selectable (3rd paragraph of the “link” event of the Text [or Label, which it is in herited from] control). Oh well… 😦
Hi,Thanks for the information. Unfortunately I still cannot find that in the documentation. I even looked on the Live Docs.But even if it was documented, I’m sure the fact that the hand icon shows up over an anchor tag that won’t dispatch an event should be considered a bug.Thanks again for the info and I’ll look a little harder to see if I can find it.
Weird–it seems to work for me(can’t paste code in here).It would be whacked if you had to set it to selectable though… exactly something you wouldn’t want to do.Phillip Kerman
Here is the behavior I see:If selectable:- Hand icon shows up on hover- Click event firedIf not selectable:- Hand icon shows up on hover- Click event not firedNow, its possible this is only in my local Flash 9 player. Perhaps I didn’t clean up properly from the beta stage of Flash.
Yeah, either your setup is whacked or I’m not understanding the problem.I’d put the PK stamp of approval on this feature. Phillip
Another problem with this text event:http://www.blog.lessrain.com/?p=584
I was facing this problem as well, and strange enough, I did not have a problem when I was working on my application as a pure AS3 project (in Flex Builder), but when I included my application in a Flex wrapper (for an AIR version), the text links stopped working (until I made the fields selectable).I have found some similar issues also earlier, and I believe there are some incompatibilities with textfields when mixing Flex and non-Flex projects together…
Thank. You.I was about to get mad about that behaviour!
Hi Jobe,This has nothing to do with being selectable, but with the fact that the textfield has to be mouseEnabled = true. Since the textfield is basically dispatching and MouseEvent. And ofcourse the text has to be htmlText = “some text” and not text = “some text”.Hope this helps you,Cheers,Sidney
I’m seeing the same behavior. Yes, mouseEnabled has to be set to true, but a link won’t send a flash event unless the text field is set to selectable! That’s maddening because it’s the opposite of what I want. Normal web links DO work regardless of if the text field is selectable or not. This seems like a flash bug… sigh.
Yes, i am having the same trouble independent of myTextField.mouseEnabled.Everything works as documented, if i create an example in CS3 standalone. But the event is not fired, if i am loading that precompiled SWF into a main application that i built using Flex Builder 3.Then i can get around by making the TextField selectable.
Im currently building a menu for a website. All links have event: links, selectable = FALSE and LINK is firing properly…
I have another problem with this Textevent.LINK (and couldn’t find anyone else discussing this specific event) namely:some people tend to doubleclick the link in which case the event is fired twice, this results in overlapping content i my case. Is there a way to prevent this from happening (other than to temporarely remove the listener or detecting it is allready active) ? if you know what i mean
Struggling with this too. This really is a bug. If the hand cursor wasn't there, one could argue its a feature. But Flash actually shows the hand cursor, but the event isn't dispatched when clicked.Still nobody out there who has a solution?
Hi,I think I've found a work around for this problem. It seems to be caused by the TextField not having focus when it it clicked on.If you manually set the focus to the TextField when you rollover it with the mouse it should work.e.g. myTextField.addEventListener(MouseEvent.ROLL_OVER, onRollOver);…private function onRollOver(event:MouseEvent):void{ stage.focus = myTextField;}I encountered this problem after embedding some Flash in a Flex app.Neil
I was trying to load a swf in a Flex app and was pulling my hair out: Why won't the text-based links from that swf open? The buttons inside the swf opened an associated url, but none of the textarea links worked. Anyways, enough ranting: Thanks for this post, and especial thanks to Neil Peirce: That work around made my night.
Hi,First thank you for the trick, I just spent LITTLE time threw this . Secondly no mention even in LiveDocs for this trick. Third in Flash it does work even if the textfield is not selectable BUT in a normal or debug player in a broswer it DOESN'T work.++Antoine
you have just solved my problem, although i do not like the selectable text *sigh*
Thanks guys, this was causing me issues too… although it only seems to work intermittently with a link as an image, where text links work every time, any ideas?
Gracias, yo tambien dure 2 dias batallando con este detalle…y no hay mucha documentacion sobre esto.Muchas gracias!
I have solved this by changing my dynamic text field in Flash to a TextArea component. The reason Flex cannot see the event is because Flex needs to use uicomponents. I then had to skin my text area with an empty movie clip but that's not a big deal for me.Thanks to everyone here that got me on the right track!
Thank you. You saved me a couple of hours atfer I have already spent two hours on finding this problem.
Thanks Jobe!
Merry Christmas and Happy New Year 2012.
An useful tip to overcome the bug which reduced much of my development time,
by the way is there any way I cn also make the TextField non-selectable at the same time ?