1 Attachment(s)
[AS2] arrays to text, rpg dialogue system
I am currently experimenting with an rpg dialogue engine and I ran into a problem. I devised this code below:
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();
}
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 will also attach the fla.