Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:16:48+00:00 2026-06-10T02:16:48+00:00

So I’ve taken it upon myself to make a ‘wiki’-esque application for some friends

  • 0

So I’ve taken it upon myself to make a ‘wiki’-esque application for some friends that works over Dropbox, which means that all the files are stored locally and updated by everyone.

Every file is a .txt pulled in by the flash and then displayed using a simple navigation and search tool.

Now I am trying to take this a step further and link articles from their content. Example:

Article 1 is called ‘Apples’. Its content: ‘Apples are delicious.’
Article 2 is called ‘Bears’. Its content: ‘Bears often eat apples.’

Now when the user opens Article 2, I would like them to be able to click on the word ‘apples’, which would then open Article 1 (‘Apples’).

I would like to know how to create events that trigger on the click of a specific word in a dynamic text box. Not the whole dynamic text box.

I have thought of creating movieclips in the shape of the word that are clickable and layering them over the word, but that is too much trouble if there is an easier option available.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:16:50+00:00Added an answer on June 10, 2026 at 2:16 am

    You can use the textbox’s htmlText property to dynamically make the words links. Then use the TextEvent.LINK event to catch the word clicked.

    Before you populate the text box with the content, simply iterate through your list of “keywords” and do a .replace("keyword", '<a href="event:keyword">keyword</a>');

    So, your code will look something similar to:

    // get the file contents using whatever method you use
    var contents:String = getFileContents("page2.txt");
    
    // assuming you have your keywords in an array
    var keywords:Array = ["Apples", "Pears"];
    for each (var keyword:String in keywords) {
        // replace the current keyword with a version of itself wrapped in a link
        contents = contents.replace(keyword, '<a href="event:' + keyword + '">' + keyword + '</a>');
    }
    
    yourTextField.htmlText = contents;
    
    // add an eventlistener for the click
    yourTextField.addEventListener(TextEvent.LINK, linkClicked);
    function linkClicked(e:TextEvent):void {
        // load the article for the clicked word =]
        loadPage(e.text);
    }
    

    UPDATE
    If you want to ignore the case of the keywords, so “apples” will match “Apples” (and so will “aPpLeS”), you’ll need to use a regular expression so that you can also keep the word as-is in the text:

    // build a |-separated list of keywords
    var keywordList:String = "";
    for each (var keyword:String in keywords) {
        keywordList += ((keywordList != "") ? "|" : "") + keyword;
    }
    // build the regex and replace each keyword in-place
    var pattern:RegExp = new RegExp("(" + keywordList + ")", "gi"); // "i" for ignore-case =]
    contents = contents.replace(pattern, '<a href="event:$1">$1</a>');
    

    The reason the above builds a |-separated list of keywords and does a single replace (as opposed to a replace for each keyword) is because the separated-list will do the replacement in-order and not allow a found keyword break the HTML inserted by a previous keyword (say, for instance, you had a keyword “event” – the HTML would break if it was replaced to make <a href="<a href="event:event">event</a>:keyword1">keyword1</a>).

    The original-case of the text will be sent with the event. You can either do a search through all of your existing keywords and compare them with the one passed to the event (convert both to lower case with .toLowerCase() for the comparison), or you can make a rule that the primary keyword is always lowercase and not have to worry about searching through the list each time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.