onEnterFrame=function(){
talking();
}
text=story[n];
story=new Array("what are we going to do about the dead body?","well dig it up and put it in my yard");
It works great if the variable "text" has a string on it. But I wanted to be able to advance to the next string so I decided to use an array to hold my dialogue texts. I placed "n" as a counter for the dialogue. The problem is that it wont put out the necessary text when I test it out. I know this is something really simple and I am very dumb for not knowing it, but after hours and hours of internet research, I have no idea what to do.
I think the problem is that you've defined the variable "text" before your array. Trying switching them around.
So it'll look something like this:
PHP Code:
i = 1;
//substring counter
function talking() {
//text typewriter
if (i<text.length) {
i++;
type = substring(text, 1, i);
} else if (i == text.length) {
type = text;
}
}
n = 0;
//dialogue counter
onEnterFrame = function () { talking();
};
story = new Array("what are we going to do about the dead body?", "well dig it up and put it in my yard");
text = story[n];