views:

51

answers:

0

Hi, I would like some help (and I'm new to this site)

I want a typewriter-effect. So that it looks like the code in the string is typed character by character (for an animation). However, I get a #1009 back. It talks about a null object reference (the error is in Dutch).

My dynamic text field is in the same scene, on a different layer. codeTekst is the instance name. It is classic, dynamic text. Multiline behaviour and not embedded in a symbol. I'm using Flash CS5. Here is my code:

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

var string:String = 'import flash.events.Event import flash.utils.Timer; import         flash.events.TimerEvent; import flash.display.MovieClip; import flash.events.MouseEvent;   import flash.media.Sound; import flash.media.SoundChannel; stop(); var   beginSchermSpraak:Sound = new BeginSchermSpraak(); var beginSchermSpraakKanaal:SoundChannel   = new SoundChannel(); var helpKnopSpraak:Sound = new HelpKnopSpraak(); var   helpKnopSpraakKanaal:SoundChannel = new SoundChannel(); var eersteKeer:Boolean; var gebouw:uint; var vandaan:Boolean; var timer:Timer = new Timer(1, 1); splashMC.x=-9001; startKnop.x=-9001; if (eersteKeer == false) { splashMC.x=250; startKnop.x=250; beginSchermSpraakKanaal = beginSchermSpraak.play(); beginSchermSpraakKanaal.addEventListener(Event.SOUND_COMPLETE, helpKnopMaken); startKnop.addEventListener(MouseEvent.CLICK, startTimer); timer.addEventListener(TimerEvent.TIMER_COMPLETE, vervaag); } else {}';

var i:uint = 0;

var timer:Timer = new Timer(10);

timer.start();

timer.addEventListener(TimerEvent.TIMER, goTime);

function goTime(e:TimerEvent){

codeTekst.appendText(string.charAt(i));
i++;

if(i>=string.length) {
    timer.stop();
}


}

Thanks for any ideas :)