Question

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.

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top