I'm running the very begninning of a program I'm going to use for a text-based adventure, and it seems to be working very well, but I've noticed a severe slowdown in my program. I've been using trace(System.totalMemory); to discover the problem and there is a very linear increase in memory, about 500b-1kb per frame.
{
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler);
function fl_EnterFrameHandler(event: Event): void {
//this block sets up the blinking cursor
var_x = var_x + 1;
if (var_x > 18) {
var_x = 0;
if (str_cursor == " ") {
str_cursor = "█";
} else {
str_cursor = " ";
}
}
//Checking to see if a picture needs to be drawn or not
if (picture != "") {
fulltext = (picture + "\n\n" + responce + "\n\n" + ">>>" + user_input + str_cursor);
} else {
fulltext = (responce + "\n\n" + ">>>" + user_input + str_cursor);
}
//Setting the interval of the draw string
uInt = setInterval(writeIt, 1);
function writeIt() {
if (!printed) {
//Finding the substring of the draw string and assignign to the text field
fl_TF.text = fulltext.substring(0, count);
count += count_speed;
if (count > fulltext.length) {
clearInterval(uInt);
//Stoping the print loop
printed = true;
count = 0;
}
} else {
user_input = inputField.text;
fl_TextToDisplay = fulltext;
fl_TF.text = fl_TextToDisplay;
}
}
if (printed) {
user_input = inputField.text;
fl_TextToDisplay = fulltext;
fl_TF.text = fl_TextToDisplay;
clearInterval(uInt);
}
}
I can't seem to find the leak, as I've traced all my variables involved to the console at different points.
You can find a screenshot of the program here: http://ift.tt/1HgXueN
Aucun commentaire:
Enregistrer un commentaire