Removing a Child within the Timer Class
I want to add a child to the stage for 5 seconds and then remove it. When I use the following code I get a "1120: Access of undefined property WordoScreen." error.
In particular the problem only occurs when I use the "removeChild(WordonScreen);" using the TIMER_COMPLETE. If I remove that statement I don't have a problem.
Here's the code:
import flash.utils.Timer;
stop();
//Adding a child to the screen
var myTestTimer:Timer = new Timer(300, 1);
myTestTimer.addEventListener(TimerEvent.TIMER, addaGraphic);
function addaGraphic (e:TimerEvent):void{
var WordonScreen:tapWords = new tapWords
addChild(WordonScreen);
WordonScreen.x = 117;
WordonScreen.y = 78;
}
myTestTimer.start();
//When timer is finished... it should go away.
myTestTimer.addEventListener(TimerEvent.TIMER_COMP LETE,timerCompleted;
function timerCompleted (e:TimerEvent):void {
removeChild(WordonScreen);
}
What am I doing wrong?