A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [AS2] arrays to text, rpg dialogue system

  1. #1
    Member
    Join Date
    Jul 2002
    Posts
    65

    [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.
    Attached Files Attached Files

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Posts
    17
    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:
    1;
    //substring counter
    function talking() {
        
    //text typewriter
        
    if (i<text.length) {
            
    i++;
            
    type substring(text1i);
        } else if (
    == text.length) {
            
    type text;
        }
    }
    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]; 

  3. #3
    Member
    Join Date
    Jul 2002
    Posts
    65
    Wow thanks! I knew it was something really simple. It totally works now!

  4. #4
    Junior Member
    Join Date
    Jun 2010
    Posts
    17
    No problem. Glad I could help.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center