We help IT Professionals succeed at work.

How do I get textHeight from xml-text

SimonAdrian
SimonAdrian asked
on
443 Views
Last Modified: 2008-12-06
How do I get the textHeight from text that comes from xml so I can use it to adjust the height of a tooltip.
I need the textHeight to adjust the height in a drawRoundedRectangle, so Im trying to make the tooltip.text  a variable, that comes from the rollOver function, but it doesnt work. Why.
Assume I have two text coming from xml: firstXmlText and seconXmlText.

If I place firstXmlText as the tipText.text like this:
tipText.text = firstXmlText;
it works fine, but what I need is this:

tipText.text = xmlTextfromRollOver;

so the rollOver function could look something like this:
square2_mc.onRollOver = function() {
      showTip();
                xmlTextfromRollOver = firstXmlText;
}
 or something like it.

You can see what Im hoping to do in the attached code snippet.






function showTip() {
	container.toolTip._visible = true;
	container.toolTip._x = _root._xmouse;
	container.toolTip._y = _root._ymouse;
        onMouseMove = function () {
		container.toolTip._x = _root._xmouse;
		container.toolTip._y = _root._ymouse;
                updateAfterEvent();
    }
}
function hideTip() {
	container.toolTip._visible = false;
}
 
var XMLFile:XML;
XMLFile = new XML();
XMLFile.ignoreWhite = true;
XMLFile.load("myxml.xml");
XMLFile.onLoad = function(success) {
	 if (success) {
		 
	     var firstXmlText = this.firstChild.childNodes[0].attributes.name;
	     var secondXmlText = this.firstChild.childNodes[1].attributes.name;
 
var maxHeight:Number = 150;
var tipText:TextField = _root.container.toolTip.createTextField("tipText", 11, 2, 2, 120, maxHeight);
    tipText.multiline = true;
    tipText.wordWrap = true;
    tipText.text = xmlText;
 
var autoHeight:Number = tipText.textHeight+12;
    autoHeight = autoHeight<maxHeight ? autoHeight : maxHeight; 
    tipText._height = autoHeight;
    container.toolTip._height = autoHeight;
drawRoundedRectangle(container.toolTip, 150, autoHeight, 16, 0x99FF00, 40);
	 }
}
hideTip();
square1_mc.onRollOver = function() {
	showTip();
         xmlText = firstXmlText;
	}
square1_mc.onRollOut = function() {
	hideTip();
}
square2_mc.onRollOver = function() {
	showTip();
         xmlText = secondXmlText;
}
square2_mc.onRollOut = function() {
	hideTip();
}

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.