I would personally do it using an Event.ENTER_FRAME
handler.
const TIME_TO_DISPLAY_ACHIEVEMENTS:uint = 2000; //ms
var achievements:Vector.<Object> = new Vector.<Object>();
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
function displayAchievement(msg){
var myTextBox:TextField = new TextField();
myTextBox.text = msg;
myTextBox.x = 50;
myTextBox.y = 20;
addChild(myTextBox);
achievements.push({tf:myTextBox, time:getTimer()});
}
function enterFrameHandler(e:Event):void {
var i:uint, l:uint, t:uint;
t = getTimer();
l = achievements.length;
for (i = l - 1; i >= 0; i--) {
if (achievements[i].time + TIME_TO_DISPLAY_ACHIEVEMENTS <= t) {
removeChild(achievements[i].tf);
achievements.splice(i, 1);
}
}
}
That's untested and I wrote it pretty quickly, so you may need to alter it to make it compile and/or run.
Basically, you add an object with the achievement and a timestamp to a Vector or array. Then on each frame, you quickly cycle backward (to account for removing objects) through and check if any have expired. If they have, you remove them from the stage and from the vector/array.
This could definitely be optimized and you could replace ENTER_FRAME with a Timer that runs every 100ms or something to save on CPU time, but it should work