如何在 Actionscript 3.0 中倾斜文本字段?

发布于 2024-08-30 07:03:16 字数 39 浏览 6 评论 0原文

如何倾斜文本字段以便为每行设置升序空间。 下图应该说明我的意图:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

述情 2024-09-06 07:03:16

知道了:
adobe

公共类 TextBlock_createTextLineExample扩展 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);
        }
    }
}

}

Got it:
adobe

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

}

腻橙味 2024-09-06 07:03:16
private static const _DEG2RAD:Number = Math.PI/180;

public static function skew(target:DisplayObject, skewXDegree:Number, skewYDegree:Number):void
{
    var m:Matrix = target.transform.matrix.clone();
    m.b = Math.tan(skewYDegree*_DEG2RAD);
    m.c = Math.tan(skewXDegree*_DEG2RAD);
    target.transform.matrix = m;
}   

public static function skewY(target:DisplayObject, skewDegree:Number):void
{
    var m:Matrix = target.transform.matrix.clone();
    m.b = Math.tan(skewDegree*_DEG2RAD);
    target.transform.matrix = m;
}       

public static function skewX(target:DisplayObject, skewDegree:Number):void
{
    var m:Matrix = target.transform.matrix.clone();
    m.c = Math.tan(skewDegree*_DEG2RAD);
    target.transform.matrix = m;
}   
private static const _DEG2RAD:Number = Math.PI/180;

public static function skew(target:DisplayObject, skewXDegree:Number, skewYDegree:Number):void
{
    var m:Matrix = target.transform.matrix.clone();
    m.b = Math.tan(skewYDegree*_DEG2RAD);
    m.c = Math.tan(skewXDegree*_DEG2RAD);
    target.transform.matrix = m;
}   

public static function skewY(target:DisplayObject, skewDegree:Number):void
{
    var m:Matrix = target.transform.matrix.clone();
    m.b = Math.tan(skewDegree*_DEG2RAD);
    target.transform.matrix = m;
}       

public static function skewX(target:DisplayObject, skewDegree:Number):void
{
    var m:Matrix = target.transform.matrix.clone();
    m.c = Math.tan(skewDegree*_DEG2RAD);
    target.transform.matrix = m;
}   
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文