CURRENT PROJECTS
loading
CATEGORIES AND POSTS
loading
overset
DEVELOPMENT LOG FOR JIM PALMER
Posted 07/11/2006 in flash


I have to admit that I'm a stickler for trying to adhere to a pixel-based grid design layout when it comes to anything, even beyond Flash. I've been struggling with Flash to gain consistent precise control of layout when it comes to MovieClip, TextField, and embedded fonts. One issue that stands out in my mind is controlling the dimensions of an instantiated/extended/composed TextField object. I've had relative success controlling the dimensions of TextField on the fly in AS2.0 as it sits in it's parent MovieClip. Usually I want the parent MovieClip to be the same dimensions as the TextField's _height and _width properties.

I've had relative success controlling this via the textHeight and textWidth properties in the AS2.0 TextField object - both with embedded and device fonts.

To gain the best control of the height for a specific font to be used in a single-line TextField, here's a snippet of code from the stock Flash IDE's mx.controls.gridclasses
function cellGetPreferredHeight()
{
	var oldText = this.text;
	this.text = "^g_p";
	this.draw();
	var tH = this.textHeight + 4;
	this.text = oldText;
	return tH;
}
This basically overwrites a Current TextField object with only the following glyphs: "^g_p". This is actually an interesting trick to ensure that you'll have an accurate reading on the maximum height of the text to be rendered in the TextField via the TextField.textHeight property.

And so we inch towards more precise control of pixel-based grid layouts in a truly vector-based environment.
comments
loading
new comment
NAME
EMAIL ME ON UPDATES
EMAIL (hidden)
URL
MESSAGE TAGS ALLOWED: <code> <a> <pre class="code [tab4|tabX|inline|bash]"> <br>
PREVIEW COMMENT
TURING TEST
gravatar