2012-08-07 80 views
0

我有一個動態的文本字段與反別名類型「使用設備字體」。當我旋轉文本時,文本消失並重新出現時文本字段已被旋轉到360度。請告訴我的方式來實現這一點。提前致謝。在Flash中旋轉文本cs5

回答

0

由於Flash Player 10可以通過調整它們的rotationZ屬性來旋轉DisplayObjects'。你也可以用你的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); 
      } 
     } 
    } 
}