0

我正在尝试使用 AS3 创建打字机效果。我在洞天阅读了教程,但找不到我要找的东西....

也许你可以帮助我。- 请

这就是我想要的: - 打字机文本效果 - 可以设置速度 - 不从外部 .as 文件导入 - 不从外部 .txt 文件导入(文本应该用变量定义) - 如果文本字段已满文本,它应该向下“滚动”……它应该向下跳一行,这样就有一个新的空行,打字机可以在其中书写……

你能帮我做动作大师吗?

我一直与 as2 合作,我很难在 as3 中找到解决方案.. :(

多谢!

4

2 回答 2

0

好吧,这听起来很简单,你所拥有的就是好的。

首先创建将显示最终文本的文本字段。您接下来要做的是一次添加所有字符,但您想要的是在一段时间后添加每个字符。

尝试类似:

import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.Timer;

// the textfield guess you will add this on timeline instead of coding it...
var myTextField:TextField = new TextField();

// this is the text that should be displayed tywriterstyle
var typewriterText:String  ="Hello World Typewriter";  

// Charackter count and timer for timedelay between each upcoming charackter
var counter:int = 0;
var delayTimer: Timer = new Timer(300);

// starts Timer
delayTimer.addEventListener(TimerEvent.TIMER, addCharackter);
delayTimer.start();

private function addCharackter( E:Event = null ):void{

    // get a single Charackter out of the String
    var charackterToAdd:String = typewriterText.charAt(counter);

    // add the charackter to the Textfield
    myTextField.text.append(charackterToAdd);
    counter++;

    // if you reached the end of the String stop Timer
    if(counter == typewriterText.length){
        delayTimer.stop();
    }
}
于 2012-04-24T11:03:32.967 回答
0

对于文本动画,您可以使用flupie。我认为这是一种更好的方法。

另请参见thisthis

如果你是一个 watch&learn 的人,对你来说会很方便。

于 2012-04-24T13:51:33.870 回答