Bottom Align Variable Length Text Fields in Flash

Getting Flash to display dynamic text the way you want it displayed can sometimes be a chore. Recently I had the need to bottom-align a dynamic text field that could vary between 1 and 3 lines high.

Here’s an example: Download source

The solution is pretty simple. The following code handles everything:

bottomCoord = text_txt._y + text_txt._height;
text_txt.autoSize = "center";

btn.onRelease=function() {
	text_txt.text = input_txt.text;
	text_txt._y = bottomCoord - text_txt._height;

First I record the bottom _y coordinate of the dynamic text field. Then I set the text field's autosize property to 'center' allowing the field to dynamically expand and contract vertically. And finally, I adjust the text field's _y position based on the new height.


SWFObject 1.5 Offers Helpful Improvements

Version 1.5 (briefly known as 2.0) of Geoff Stearns’ SWFObject flash embedding script was released at the end of February. The new version offers a couple of useful changes.

Express Installation now requires no ActionScript in your source FLA. The checking is now done by an external SWF which can be centralized or placed with your swf. Source code is provided for tweaking and customization.

Geoff also added support for style tags on the outputted object/embed code allowing it to be used with apps like SWFir without having to include the SWFObject code multiple times.

No updates on SWFfix (the next generation flash embedding technique) since the test suite matrix was released in early February. I feel like Neo every time I look at that thing!