Hey all.
Let me preface this by saying that I’m fairly new to Actionscript, so I’ll bet there’s an easy answer to this. I’ve also searched all over and can’t find an answer for what I’m trying to do, though I may not be using the right terms.
Basically I have a textfield that will have a fixed width and wrap the text, which will be passed to it dynamically. Since the text will be dynamic,there’s no guarantee of how many lines the text will take up.
Directly underneath that textfield i have another text field that will also take dynamic text. Think of it as a title and a subtitle.
so I’ll have something like this:
var title:TextField = new TextField();
var subtitle:TextField = new TextField();
title.wordWrap = true;
title.autoSize = "left";
title.width = 300;
title.Text = "this is a title";
(plus an addChild, and similar code to set up the subtitle)
So my problem is getting the subtitle to align properly under the title no matter how many lines the text takes up. I’ve tried several variations on setting the y value for the subtitle, including each of the following:
subtitle.y = title.y + title.height;
subtitle.y = title.y + title.textHeight;
subtitle.y = title.textHeight * title.numLines;
and probably others that I’m forgetting. Getting it to work with a single line of text isn’t really a problem, but as soon as the text begins to wrap to multiple lines, everything i’ve tried seems to fall apart.
Can anyone clue me in on how to make this work?