[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

Calling a function on text hover

Hello,

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! : )
0
ashugarg00
Asked:
ashugarg00
1 Solution
 
negatyveCommented:
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...
0
 
blue-genieCommented:
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.

blu.
0
 
blue-genieCommented:
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;
            trace(menuItem);
      }
      _root.test = menuItem;
};
menuXml.load("test.xml");

and my xml looks like so:

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

and works dandy.
blu.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ashugarg00Author Commented:
I want to handle HOVER not clicks!
0
 
blue-genieCommented:
well alrighty then.

I'll PASS on this one.
0
 
CyanBlueCommented:
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...  :)
0
 
ashugarg00Author Commented:
Sorry blue-genie, didn't mean to **YELL** : ) .
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now