views:

1759

answers:

5

How do you rotate a text field in actionscript 3.0? As soon as I change the rotation property of the text field, it does not display.

for example:

var txtFld:TextField = new TextField();
txtFld.x = 100;
txtFld.y = 100;
txtFld.width = 300;
txtFld.height = 300;
txtFld.text = "Test String";
txtFld.rotation = 90;
addChild(txtFld);
+3  A: 

In order to see rotated text, you'll have to embed the font.

Christophe Herreman
+1  A: 

Some more info supporting Christophe Herreman : ActionScript - Rotating Text

Shoban
+1  A: 

an alternative is, to copy the textfield into a BitmapData using BitmapData::draw and then creating a Bitmap containing the result, and adding that one to the display list, instead of the original TextField ...

this has the great advantage, that you don't need to embed the font, which reduces swf filesize ... OTOH, you will lose all of the TextField`'s interactivity, and the swf will need more RAM when playing, but the latter is not too significant ...

for the text to look smooth, set Bitmap::smoothing to true ... also, it helps, if you render your image at a higher resolution ... pseudo-anti-aliasing, so to speak ... when drawing the text, pass a Matrix scaled up by factor 2 and scale down the Bitmap by factor 2 ... that way it'll look better ...

back2dos
A: 

back2dos - thats great .. can we see an example?

shawn
A: 
var txtFld:TextField = new TextField();
txtFld.x = 100;
txtFld.y = 100;
txtFld.width = 300;
txtFld.height = 300;
txtFld.text = "Test String";

txtFld.embedFonts = true; // to embed the font ... now roation works

txtFld.rotation = 90;
addChild(txtFld);
Benedikt