在flash cs5中旋转文本字段

时间:2012-08-07 13:44:24

标签: flash-cs5

我有一个带有反别名类型“使用设备字体”的动态文本字段。当我旋转文本字段时,文本消失并在文本字段旋转到360度时重新出现。请建议我实现此目的。提前谢谢。

1 个答案:

答案 0 :(得分:0)

从Flash Player 10开始,您可以通过调整DisplayObjects'属性来轮换rotationZ。您也可以使用TextField执行此操作。除此之外,您还可以使用TextBlock类来解析TextLines并相应地轮换它们。

有关更多信息,请查看此博文:

http://www.yswfblog.com/blog/2009/05/21/the-knack-to-rotating-dynamic-text-in-flash-10/

这是来自同一篇博文的代码:

package 
{
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.engine.*;

    public class TextTest extends Sprite 
    {
        public function TextTest () 
        {
            for (var i:int = 0; i <= 20; i++) 
            {
                var txt:TextField = new TextField();
                txt.selectable = false;
                txt.width = 300;
                txt.height = 100;
                txt.text = "Hello world!";
                txt.setTextFormat(new TextFormat("Georgia", 2 + 2*i));

                txt.x = 6*(i*(i+1)/2);
                txt.y = 30;
                txt.rotationZ = 20;
                addChild(txt);
            }

            for (var j:int=0; j<=20; j++) 
            {
                trace(j);
                var myString:String = "Hello world!";
                var myFormat:ElementFormat = new ElementFormat();

                var myFontDesc:FontDescription = new FontDescription("Georgia");
                myFormat.fontSize = 2 + 2*j;
                myFormat.fontDescription = myFontDesc; 

                var textElement:TextElement = new TextElement(myString, myFormat);
                var textBlock:TextBlock = new TextBlock();
                textBlock.content = textElement; 

                var myTextLine:TextLine = textBlock.createTextLine(null, 300); 

                myTextLine.x = 6*(j*(j+1)/2);
                myTextLine.y = 150;
                myTextLine.rotation = 20;

                addChild(myTextLine);
            }
        }
    }
}
相关问题