SWFFont

$f = new SWFFont(name);

If name is the name of an FDB file (i.e., it ends in ".fdb"), load the font definition found in said file. Otherwise, create a browser-defined font reference.

FDB ("font definition block") is a very simple wrapper for the SWF DefineFont2 block which contains a full description of a font. One may create FDB files from SWT Generator template files with the included makefdb utility- look in the util directory off the main ming distribution directory.

Browser-defined fonts don't contain any information about the font other than its name. It is assumed that the font definition will be provided by the movie player. The fonts _serif, _sans, and _typewriter should always be available. For example:

$f = newSWFFont("_sans");
will give you the standard sans-serif font, probably the same as what you'd get with <font face="sans"> in html.

Returns a reference to the font definition, for use in setFont below.


SWFText

$t = new SWFText();

Create a new text object, fresh for manipulatin'.

$t->setFont($f);

Set the current font to $f.

$t->setHeight(height);

Set the current font height to height. Default is 240.

$t->setSpacing(spacing);

Set the current font spacing to spacing. Default is 1.0. 0 is all of the letters written at the same point. This doesn't really work that well because it inflates the advance across the letter, doesn't add the same amount of spacing between the letters. I should try and explain that better, prolly. Or just fix the damn thing to do constant spacing. This was really just a way to figure out how letter advances work, anyway..

$t->setColor(r, g, b);
$t->setColor(r, g, b, a);

Change the current text color. Default is black. I think.

$t->moveTo(x, y);

Move the pen (or cursor, if that makes more sense) to (x,y) in text object's coordinate space. If either is zero, though, value in that dimension stays the same. Annoying, should be fixed.

$t->addString(text);

Draw the string text at the current pen (cursor) location. Pen is at the baseline of the text; i.e., ascending text is in the -y direction.

Example code


SWFTextField

Text Fields are less flexible than Text objects- they can't be rotated, scaled non-proportionally, or skewed, but they can be used as form entries, and they can use browser-defined fonts.

$t = new SWFTextField();
$t = new SWFTextField(flags);

Create a new text field object.

The optional flags change the text field's behavior:

SWFTEXTFIELD_NOEDIT indicates that the field shouldn't be user-editable
SWFTEXTFIELD_PASSWORD obscures the data entry
SWFTEXTFIELD_DRAWBOX draws the outline of the textfield
SWFTEXTFIELD_MULTILINE allows multiple lines
SWFTEXTFIELD_WORDWRAP allows text to wrap
SWFTEXTFIELD_NOSELECT .. no idea.
Flags are combined with the bitwise OR operation. For example,
$t = newSWFTextField(SWFTEXTFIELD_PASSWORD | SWFTEXTFIELD_NOEDIT);
creates a totally useless non-editable password field.

$t->setFont($f);

Set the text field font to the browser-defined font $f.

$t->setBounds(width, height);

Set the text field width and height. If you don't set the bounds yourself, Ming makes a poor guess at what the bounds are.

$t->align(alignment);

Set the text field alignment. Legit values are:
SWFTEXTFIELD_ALIGN_LEFT
SWFTEXTFIELD_ALIGN_RIGHT
SWFTEXTFIELD_ALIGN_CENTER
SWFTEXTFIELD_ALIGN_JUSTIFY

$t->setHeigth(height);

Set the font height of this text field font to the given height. Default is 240.

$t->setLeftMargin(num);

Set the left margin width of the text field. Default is 0.

$t->setRightMargin(num);

Set the right margin width of the text field. Default is 0.

$t->setMargins(left, right);

Set both margins at once, for the man on the go.

$t->setIndentation(num);

Set the indentation of the first line in the text field.

$t->setLineSpacing($f);

Set the line spacing of the text field. Default is 40.

$t->setColor($r, $g, $b); $t->setColor($r, $g, $b, $alpha);

Set the color of the text field. Default is fully opaque black.

$t->setName(name);

Set the variable name of this text field, for form posting purposes.

$t->addString(string);

Concatenate the given string to the text field.

Example code


All content Copyright (C) 2000 Opaque Industries except where noted otherwise.