Just for the archives..... I'll reply to myself. :)
On Aug 30, 2007, at 7:46 AM, Jon Bradley wrote:
The trick I want to use is as follows:
1. Class MyLabel (extends Sprite) contains one reference to
MyTextField class - an extension of UITextField. It also contains one
Bitmap.
MyLabel extends UIComponent. It contains an instance of the
UITextField and the Bitmap that will be used to display that field.
2. When a transformation is applied (transform.matrix) to the MyLabel
class, the transformation is captured and split into it's components
- scale, then rotation/skew. It's easy to split up these components.
Depends on the transformation method one uses. For something like
senocular's wonderful TransformTool, you need to override the "apply"
method and call something like "setTransform" rather than directly
apply the transform.matrix. Unfortunately, you can't capture the
application of a transform to a DisplayObject natively.
A change in the parent transformation may also be made and one can
register to listen for that event, triggering an invalidation routine
that does the drawing and hides the original field (cancel nested
transform, draw, reset transform back to normal).
The trick here was do do the following basically, taken from my
setTransform method. This works very well.
1. Get the scale factor
2. Reset transformation on the UIComponent
3. Apply scale transformation on the text field - drawField(). This
makes the UITextField visible just during that method to perform the
draw routine.
4. Reset the transformation on the UITextField
5. Apply the inverse transformation to the bitmap that's used to
display it (so that in effect, all transformations are canceled
internally to the UIComponent. Everything is kosher with external
transformations now.
6. Apply transformation as requested to the entire clip
public function setTransform(m:Matrix):Matrix {
var sx:Number = Math.sqrt(m.a * m.a + m.b * m.b);
var sy:Number = Math.sqrt(m.c * m.c + m.d * m.d);
var newMat:Matrix = new Matrix();
newMat.scale(sx,sy);
transform.matrix = new Matrix();
relatedField.transform.matrix = newMat;
drawField();
relatedField.transform.matrix = new Matrix();
// reverse the given transformation on the bitmap
text
newMat.invert();
bitmapText.transform.matrix = newMat;
transform.matrix = m;
return m;
}
Yay. Rotation is then relatively easy to support for non-embedded
font outlines with this method. Quality is pretty nice as well. Maybe
one of these days Adobe will get rotation of device fonts working and
we won't need to perform hacks like this.
cheers,
jon