Setting dynamic widths for textfields in as3?
I have 3 textfields. they're in a sprite container. 1. date 2. pipe_mc movieclip 3. title field. I need to set it so that the textfield/mc/textfield;s x property changes dynamically when a shorter or longer date gets added into the field, via XML.
Here is the code:
addChild(dateline);
dateline.addChild(date_txt);
dateline.addChild(title_txt);
dateline.addChild(pipe_mc);
date_txt.x = 3;
var spacer:Number = 10;
if (date_txt.textWidth >= 90) {
pipe_mc.x = date_txt.x + date_txt.width + 18;
title_txt.x = pipe_mc.x + pipe_mc.width + spacer;
}
else if (date_txt.textWidth <= 90) {
pipe_mc.x = date_txt.x + date_txt.width - 18;
title_txt.x = pipe_mc.x + pipe_mc.width + spacer;
pipe_mc.visible = true;
}
Any help or suggestions are welcome
Thanks