Question : How do I get information from a function outside the function

In a showtip function I have some text, which has a textHeight, that I need outside the function to create a drawrectangle.
But how do I get the number outside the function to use in the drawrectangle.
The text varies in length and is based on xml

square_mc.onRollOver = function() {
                showTip(someXmlText);
}

function showTip(str) {
      container.toolTip.tipText.text = str;
      autoHeight = container.toolTip.tipText.textHeight;     //This is the number I need in the drawRoundedRectangle below
      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();
    }
}

drawRoundedRectangle(container.toolTip, ttWidth, autoHeight, 16, 0x99FF00, 100);

Answer : How do I get information from a function outside the function

Regards,
Jon


var autoHeight;

function showTip (str)
{
      container.toolTip.tipText.text = str;
      autoHeight = container.toolTip.tipText.textHeight;
      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;
}

function drawRoundedRectangle (target_mc:MovieClip, boxWidth:Number, boxHeight:Number, cornerRadius:Number, fillColor:Number, fillAlpha:Number):Void
{
      target_mc.createEmptyMovieClip("square_mc", this.getNextHighestDepth());

      with (target_mc.square_mc)
      {

            beginFill (0x00CCCC,100);
            lineStyle (2,0x00CCCC,100);
            moveTo (cornerRadius,0);
            lineTo (boxWidth - cornerRadius,0);
            curveTo (boxWidth,0,boxWidth,cornerRadius);
            lineTo (boxWidth,cornerRadius);
            lineTo (boxWidth,boxHeight - cornerRadius);
            curveTo (boxWidth,boxHeight,boxWidth - cornerRadius,boxHeight);
            lineTo (cornerRadius,boxHeight);
            curveTo (0,boxHeight,0,boxHeight - cornerRadius);
            lineTo (0,boxHeight - cornerRadius);
            lineTo (0,cornerRadius);
            curveTo (0,0,cornerRadius,0);
            lineTo (cornerRadius,0);
            endFill ();
      }
}
var firstXmlText = "The FLVPlayback component has been updated to support the H.264 codec, for both ActionScript 2.0 and ActionScript 3.0 versions.";
var secondXmlText = "This text is instead of xml-text";

_root.createEmptyMovieClip ("container",8);
container.createEmptyMovieClip ("toolTip",10);
container.toolTip._x = 100;
container.toolTip._y = 100;
var ttWidth:Number = 100;
var maxHeight:Number = 120;
var tiptext_fmt:TextFormat = new TextFormat ();
tiptext_fmt.font = arial;
tiptext_fmt.size = 10;
var tipText:TextField = _root.container.toolTip.createTextField ("tipText", 11, 2, 2, ttWidth, maxHeight);
tipText.multiline = true;
tipText.wordWrap = true;
tipText.text = firstXmlText;
tipText.setTextFormat (tiptext_fmt);

square1_mc.onRollOver = function ()
{
      showTip (firstXmlText);
      drawRoundedRectangle (container.toolTip,ttWidth,autoHeight,6,0x99FF00,100);
};
square1_mc.onRollOut = function ()
{
      hideTip ();
};
square2_mc.onRollOver = function ()
{
      showTip (secondXmlText);
      drawRoundedRectangle (container.toolTip,ttWidth,autoHeight,6,0x99FF00,100);
};
square2_mc.onRollOut = function ()
{
      hideTip ();
};
Random Solutions  
 
programming4us programming4us