如何歪斜在ActionScript 3.0的Textfield?歪斜、ActionScript、Textfield

2023-09-08 15:32:39 作者:看不到未来,回不到过去

我如何扭曲一个文本字段,以便设置在各行中上升的空间。 下面的图片应该说明我的意图:

How can I skew a Textfield in order to set a ascending space for each line. Following image should illustrate my intention:

推荐答案

明白了: 土坯

公共类TextBlock_createTextLineExample扩展Sprite {

public class TextBlock_createTextLineExample extends Sprite {

    public function TextBlock_createTextLineExample():void {

        var str:String = "I am a TextElement, created from a String and assigned " +
        "to the content property of a TextBlock. The createTextLine() method " +
        "then created these lines, 300 pixels wide, for display." ;

        var fontDescription:FontDescription = new FontDescription("Arial");
        var format:ElementFormat = new ElementFormat(fontDescription);
        format.fontSize = 16;
        var textElement:TextElement = new TextElement(str, format); 
        var textBlock:TextBlock = new TextBlock();
        textBlock.content = textElement; 
        createLines(textBlock); 
    }

    private function createLines(textBlock:TextBlock):void 
    {            
        var lineWidth:Number = 300;
        var xPos:Number = 15.0;
        var yPos:Number = 20.0;

        var textLine:TextLine = textBlock.createTextLine (null, lineWidth);
        while (textLine)
        {
            //increase textLine every Line 10 px to get an offset 
            textLine.x += 10
            textLine.y = yPos;
            yPos += textLine.height + 2;
            addChild (textLine);
            textLine = textBlock.createTextLine (textLine, lineWidth);
        }
    }
}

}