Advertisement

07.08.2008 at 01:14AM PDT, ID: 23545763 | Points: 500
[x]
Attachment Details

How do I autosize Movieclip to the height of textfield

Asked by SimonAdrian in ActionScript, Macromedia Flash

Tags:

Im trying to make a tooltip-movieclip, that should autosize to the content of the text.

The problem is that when I replace the heightparameter in the drawRectangle function with the autoHeight variable I get a trace of the tipText.textHeight that says 15 - like one line of text. If I write an actual height like 150, the trace says 120.

How do I make the tooltip-movie adjust to the height or size of the text.

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
this.createEmptyMovieClip("toolTip", 10);
function drawRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, fillColor:Number, fillAlpha:Number):Void {
    with (target_mc) {
        lineStyle(2,0x000000,100);
        beginFill(fillColor, fillAlpha);
        moveTo(0, 0);
        lineTo(boxWidth, 0);
        lineTo(boxWidth, boxHeight);
        lineTo(0, boxHeight);
        lineTo(0, 0);
        endFill();
}
var tipText:TextField = toolTip.createTextField("tipText", this.getNextHighestDepth(), 4, 4, boxWidth-4, boxHeight-4);
        tipText.multiline = true;
        tipText.wordWrap = true;
        tipText.autoSize = true;
        tipText.text = "New articles available on Developer Center. The preceding code dynamically creates a new text field, enables HTML formatting, and displays the text 'New articles available on Developer Center' on the Stage, with the word 'Developer Center' appearing in italics.";
 
var autoHeight = tipText.textHeight;
		}
drawRectangle(toolTip, 240, autoHeight, 0x99FF00, 100);
[+][-]07.08.2008 at 04:57AM PDT, ID: 21952820

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.08.2008 at 05:50AM PDT, ID: 21953230

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.08.2008 at 07:15AM PDT, ID: 21954035

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.08.2008 at 08:08AM PDT, ID: 21954526

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628