Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionscript: How do I rotate a text field?

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);
like image 879
Nick Sonneveld Avatar asked Jul 13 '09 06:07

Nick Sonneveld


3 Answers

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

like image 115
Christophe Herreman Avatar answered Nov 01 '22 21:11

Christophe Herreman


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 ...

greetz

back2dos

like image 5
back2dos Avatar answered Nov 01 '22 23:11

back2dos


Some more info supporting Christophe Herreman : ActionScript - Rotating Text

like image 4
Shoban Avatar answered Nov 01 '22 21:11

Shoban