I have a quite long classic text in a dynamic text field, with an UIScrollBar to scroll it. It has many references inside, part to sites in the web, part to other texts that I distributed in different frames of a movieclip with the text field inside. I have no problem linking to external websites from inside the text using the link and target fields in the properties panel. I have no problem using buttons to link to specific frames using functions with the gotoAndStop method. But I can't navigate to specific frames from selected words inside the text. Actually, I can't even navigate to files inside my computer using the link and target fields in the properties panel. Html tags are not being rendered, even with the "Render text as html" button clicked. I can't change the text to static because of the scroll bar. I can't also use invisible buttons behind the words because the scrolling would make them out of place. I don't see how a var could help me, cause it makes the text field show only the selected words. Anchors seem not to help also, since I can't target a file, but only http. Any ideas will be very welcome.
Asked
Active
Viewed 1,605 times
1 Answers
2
What you want is possible. But it comes with a little drawback thanks to a flash textfield bug. First your textfield text needs to be html text and also selectable. Then look here: Textfield link event
public function TextField_event_link() {
myMP3 = new Sound();
var text:TextField = new TextField();
text.autoSize = TextFieldAutoSize.LEFT;
text.multiline = true;
text.htmlText = "Hello this is my little site. Click <a href=\"event:imprint\">here</a>for the imprint. And <a href=\"event:imprint\">here</a> for the about page. And if you're coming so far, also <a href=\"event:imprint\">here</a> for the exit";
list.addEventListener(TextEvent.LINK, linkHandler);
addChild(list);
}
private function linkHandler(linkEvent:TextEvent):void {
switch(linkEvent.text)
{
case "imprint":
//display imprint
break;
case "about":
//display about
break;
case "exit":
//exit
break;
}
}
You can compare the event name in the handler and do your magic. If your text is not selectable this will not work. Dono if Adobe has fixed that issue with the latest player but this bugged me for years!

Larusso
- 1,121
- 8
- 10
-
Thx, but I still don't get how to make this work in a text field containing other words that don't link to anything. But I also couldn't fully explore the Adobe page you indicated, cause Chrome isn't being able to fully translate it from german. But I'll keep trying. Any hint on how to do it considering the non-linking words in the text field? – Anna Barbara Medeiros May 13 '12 at 15:10
-
It worked! I just placed the tags inside of an external txt file and used target='_self'. Thank you so much, Larusso. – Anna Barbara Medeiros May 13 '12 at 17:13
-
Glad to help. Sorry for the german doc site. Did not bother to change the language. German - English dont see the difference anymore ;) – Larusso May 13 '12 at 17:18
-
I don't know if I should create a new topic, cause my new question is subsequent to the original one, and maybe it'll be simple for you, Larusso. Can't I have more than one eventlistener in the same textfield? – Anna Barbara Medeiros May 16 '12 at 00:33
-
When the answer works for you could you please mark it as answered. Greetz – Larusso May 17 '12 at 14:53