flash - 多行手写

标签 flash apache-flex textarea multiline handwriting

我需要在 Flex 中开发一个动画来模拟某人手写带有动态内容的文本区域。 我不关心笔是否跟随字体的实际曲线,但我需要一种干净的方式来逐行显示文本,并带有跟随笔位置的 mask 。

类似这样的东西,但有原生文本区域和我自己的字体:

http://activeden.net/item/handwriting-animation-tool-v25/11733

mxml 中的 textarea 只能有一个掩码,所以我想我应该以编程方式创建我的掩码。 有人做过吗?

谢谢

最佳答案

有几种不同的技术可以创建真实效果 - 就像该网站上显示的那样。请注意,这是一项非常乏味的工作。 您可以在 Flex 中做的是按顺序显示文本行,以显示带有任何形状掩码的字母。这是一个简单的例子:

<fx:Script>
    <![CDATA[
        import mx.graphics.SolidColor;

        import spark.components.Group;
        import spark.components.RichText;
        import spark.primitives.Rect;

        private function createMultilineMask():void
        {               
            var txt:RichText = new RichText();
            txt.x = 20;
            txt.width = 260;
            txt.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus, eros ac dignissim interdum...";
            txt.setStyle('fontFamily', 'Times');
            txt.setStyle('fontStyle', 'italic');
            txt.setStyle('fontSize', 16);
            txt.setStyle('color', 0xFF0000);                

            var textMask:Group = new Group();

            var ln1:Rect = new Rect();
            ln1.x = 0;
            ln1.y = 0;
            ln1.width = 0;
            ln1.height = 14;
            ln1.fill = new SolidColor(0x000000);
            textMask.addElement(ln1);

            var ln2:Rect = new Rect();
            ln2.x = 0;
            ln2.y = 20;
            ln2.width = 0;
            ln2.height = 14;
            ln2.fill = new SolidColor(0x000000);
            textMask.addElement(ln2);

            var ln3:Rect = new Rect();
            ln3.x = 0;
            ln3.y = 40;
            ln3.width = 0;
            ln3.height = 14;
            ln3.fill = new SolidColor(0x000000);
            textMask.addElement(ln3);

            var container:Group = new Group();
            container.x = 100;
            container.y = 100;
            container.mask = textMask;
            container.maskType = 'clip';
            container.addElement(txt);
            addElement(container);

            addEventListener(Event.ENTER_FRAME, drawLine);

            function drawLine(event:Event):void
            {
                if (ln1.width < 300)
                    ln1.width += 2;
                else if (ln2.width < 300)
                    ln2.width += 2;
                else if (ln3.width < 300)
                    ln3.width += 2;
                else
                    removeEventListener(Event.ENTER_FRAME, drawLine);
            }
        }
    ]]>
</fx:Script>

HTH 金融时报

关于flash - 多行手写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5043662/

相关文章:

flash - 有关如何创建和显示youtube批注的技术说明?

apache-flex - 是否可以在 ASDoc 中包含示例 mxml?

html - Vimeo 播放器无法在 Firefox 上运行

Flash/AS3 - 如何获取在 Flash 中绘制的路径的点

apache-flex - 为什么 mx :states have trouble being resolved to a component implementation?

Python 无法正确处理来自 HTML 文本区域的文本输入

javascript - 文本区域中文本的实时渲染

javascript - 如何在打字时以正确的大小渲染文本区域并自动扩展?

flash - 无法在 Flash IDE 中导入 fl.controls

actionscript-3 - 如何在 Actionscript 3 中构建影片剪辑