Calling a function on text hover


I would like to know if there is any way to call a function in Flash when the user hovers over a particular character/s in a text box.

For example in the text "Roll over THIS to blah blah...", when the user rolls over the text "THIS", I need to call a function i've defined.

My main problems are -

1. How do I catch a hover on a text box?
2. How do I know over which characters the hover has occured?

The text box content is dynamically being read from an XML file, with tags indicating the characters that serve as the "hit-area" for the roll over

Thanks! : )
Who is Participating?
You cannot. You could with static text using the TextSnapshot object, or creating invisible buttons over the words with elaborate scripts which measure words position, but you should use a monospace charset...
you can use a dynamic text field and an asFunction. this example is with txt file, never tried it with xml file.

function loadMov() {
      loadMovie("swf1.swf", _root);
loadVariablesNum("loader.txt", 0);
then your txt looks like this:

test=There is a land that you can see, although it sometimes isn't there, and that's where you'll find a bee, with so much happiness to share, and if you ask her for her name she'll say it's Maya, the one and only little bee called Maya.<A HREF='asfunction:loadMov'>Click here</a> to see Maya's favourite colour.

your textbox has var set to test
and is html enabled. so when click on the "Click here" bit, will call loadMov function.

i just tested it with xml as in

function loadMov() {
      loadMovie("swf1.swf", _root);
menuXml = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function(success) {
      if (success) {
            menuItem = this.firstChild.firstChild.firstChild.childNodes;
      _root.test = menuItem;

and my xml looks like so:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
        <id><A HREF='asfunction:loadMov'>Click here</a></id>

and works dandy.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ashugarg00Author Commented:
I want to handle HOVER not clicks!
well alrighty then.

I'll PASS on this one.
How about moving the textField into the movieClip and check with the movieClip.onRollOver to do what you are trying to do???
If you need to know the individual text value, you will need to have a holder movieClip that contains multiple movieClips that include individual characters...  :)
ashugarg00Author Commented:
Sorry blue-genie, didn't mean to **YELL** : ) .
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.