With cues from Li, I think I figured out how to get TextField3D to
work consistently and render properly with Flash CS3:
1. In the fla, open the library, and at the pull down select New
Font...
2. In the font's properties dialog, enter "myCalibri" (or anything)
for name, and select the desired font and style. SELECT A FONT THAT
YOU WILL NOT USE ANYWHERE ON THE STAGE.
3. Open the font's linkage properties, select Export for ActionScript,
leave the base class as flash.text.Font, and for the Class, enter
"myCalibriClass".
4. In the AS, put:
import wumedia.vector.VectorText;
Font.registerFont(myCalibriClass); // Must match the font class
name given in the linkage properties
VectorText.extractFont(root.loaderInfo.bytes);
This must be executed only ONCE and BEFORE you declare any TextField3D
variables. This code loads the font data into _fontDefinitions which
is a static class variable in class VectorText, and therefore globally
available at any time after it is loaded.
5. Whenever you want to create a text object, put:
var textfield:TextField3D = new TextField3D("Calibri", {textColor:
0x0000FF, text:"Hello!", size:100, leading:500, kerning:0, textWidth:
10000, align:"TL"});
view.scene.addChildren( textfield );
Be careful if you have this code in a class linked to a symbol and you
have the register/extract code in the timeline script: it can easily
run before the timeline script, so the font is not yet loaded, so you
get nothing.
6. If you mix TextField3D with LineSegment objects (or indeed, any
surface that intersects with a LineSegment), the Flash 9 player may
render them with crazy extraneous fills. However if you play the same
SWF in Flash 10 player, it seems to render correctly. (This is the
workaround to the Issue 49 bug.) You can play the SWF either with the
browser plug or with the Flash 10 debug standalone player.
A few notes:
a) The first parameter in the TextField3D constructor must be the
actual font name (e.g. "Calibri"), not the link properties class name
("myCalibriClass").
b) The text will have zero thickness and will lie in the X-Y plane.
The text direction is towards +X. The starting point is according to
the align parameter, e.g. "TL" means the top left corner of the string
will be at 0,0,0.
c) TextField3D extends Mesh so you can move it around with x, y, z,
rotationX, etc. properties, but the text color, string, and other
properties can only be set via the init object when it is
instantiated.
d) If you load a font with VectorText but use the same font even as
static text on the stage, and you mix bold non-bold on the stage, it
will cause the TextField3D to fail to render, or sometimes crash
Away3D. I presume that when VectorText digs through the whole SWF
looking for fonts it gets corrupted if the font is also used in
different ways on the stage. (Making an instance of dynamic text on
the stage and embedding the fonts there did not seem to help, BTW).
It seems reliable if you dedicate a font for exclusive use of
TextField3D.
Not sure this is the best way to do it, but it seems to function...
Thanks again to Li for bring 3D text to Away3D!