2009-07-13 19 views
6

¿Cómo rotar un campo de texto en actionscript 3.0? Tan pronto como cambio la propiedad de rotación del campo de texto, no se muestra.Actionscript: ¿Cómo giro un campo de texto?

por ejemplo:

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); 

Respuesta

8

Para ver texto girado, que tendrá que incorporar la fuente.

5

una alternativa es, para copiar el campo de texto en un BitmapData usando BitmapData::draw y luego crear un Bitmap que contiene el resultado, y añadiendo que uno de la lista de visualización, en lugar de la original TextField ...

esto tiene la gran ventaja, que no es necesario incrustar la fuente, lo que reduce swf filesize ... OTOH, perderá toda la interactividad de TextField`, y el swf necesitará más RAM al jugar, pero este último no es demasiado significativo ...

para que el texto se vea suave, establezca Bitmap::smoothing en true ... también ayuda, si representa la imagen con una resolución mayor ... pseudo-anti-aliasing, por así decirlo ... al dibujar el texto , pasar una Matrix ampliadas por el factor 2 y reducir la amplitud del Bitmap por el factor 2 ... de esa manera que se verá mejor ...

greetz

back2dos

0
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); 
1

solo quería para agregar mi experiencia a esta pregunta. Yo también quería rotar el texto.

Al principio, incrustó la fuente utilizando solo ActionScript.

Embed(source="C:\\WINDOWS\\Fonts\\CALIBRI.TTF", fontFamily="Calibri")] 
public static const FONT_CALIBRI:Class; 
... 
var font:Font = new Global.FONT_CALIBRI as Font; 
//Font.registerFont(Global.FONT_CALIBRI); //I tried various other things... 

Pero cada vez que puse embedFonts = true, el texto desaparecería. Finalmente me rendí y embedded the font using Flash.

var font:Font = new FontClass as Font; //FontClass was exported from Flash IDE 

Finalmente funcionó.

var textFormat:TextFormat = new TextFormat(font.fontName); 

textField = new TextField(); 
textField.defaultTextFormat = textFormat; //must be before setting the text 
textField.embedFonts = true; //needed to rotate fonts 
textField.autoSize = TextFieldAutoSize.CENTER; 
textField.antiAliasType = flash.text.AntiAliasType.ADVANCED; 
textField.text = ("TESTING") 
this.addChild(textField); 

Oh, cómo detesto usar Flash IDE para nada. Si alguien pudo hacer esto sin usar Flash, ¡por favor comparte!

1

Esto es lo que funcionó para mí.

En CS5, tuve que cambiar una configuración en el cuadro de diálogo Insertar fuente para que funcione.

Para mostrar el cuadro de diálogo Insertar fuente, haga clic en el botón Insertar en el panel Carácter, o haga doble clic en el símbolo de Fuente en la Biblioteca.

A continuación, seleccione la fuente que desea rotar y haga clic en la pestaña Actionscript.

Finalmente, marca la casilla de verificación Exportar para Actionscript. Deje los valores predeterminados y haga clic en Aceptar.

A continuación se muestra el código que he utilizado:

textField = new TextField(); 
textField.autoSize = TextFieldAutoSize.LEFT; 
textField.embedFonts = true; 

format.font = "Arial"; // Or whatever the name of your font is in the embed dialog 
format.size = 24; 
textField.defaultTextFormat = format; 

addChild(textField); 

Si a continuación, a continuación, aplicar la rotación a ese campo a través de AS, sigo sin ver la fuente.

Cuestiones relacionadas