0
votes

I'm trying to create a typewriter effect with AS3. I read tutorials the hole day, but can't find, what I'm looking for....

Perhaps you can help me. - please

That's what I want: - a typewriter text effect - the speed can be set - no import from an external .as file - no import from an external .txt file (the text should be defined with a variable) - if the textfield is full of text, it should be "scroll" down....it should jump down one line, so that theres a new empty line, where the typewriter could write....

could you actionscript gurus help me?

I always worked with as2 and it's very hard for me to get a solution in as3.. :(

thanks a lot!

2
Are you getting any errors at all?Ste
no but it's not working, because there's no typewriter effect. Only the dynamic text will be shown - static...Ronny
the matrix has the example's data; where's yours?Grigorash Vasilij

2 Answers

0
votes

Ok that sounds simple what you have is good.

firtst create the textfield that will display the final text. What you did next is adding all charackters at once, but what you want is adding each charackter after a time.

try something like:

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();
    }
}
0
votes

For text animation you can use flupie. I think it's a better way to do.

See also this and this.

If you are a watch&learn guy this would be much convenient to you.