Link to home
Start Free TrialLog in
Avatar of SimonAdrian
SimonAdrian

asked on

How do I get textHeight from xml-text

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

ASKER CERTIFIED SOLUTION
Avatar of rascalpants
rascalpants
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial