Need help with clearInterval thingie

HI everyone…

Okay just a quick shoot…after being spending an hours,a day…still missing something which is I can find out…so I’m stuck up here…and really need help here…

what I want really need help is how to clear the interval after it’s read the last length of my value in array…because currently what I have it’s only read the 1st value in array and then clear the interval…as u guy’s can see in this portion code…



for(var i:Number=0;i<TextToDisplay.length;i++){
           
            trace(TextToDisplay*.substr(0,char));
//output //////////////
/*
L
Lo
Lor
Lore
Lorem
Lorem 
Lorem i
Lorem ip
Lorem ips
Lorem ipsu
Lorem ipsum
Lorem ipsum 
Lorem ipsum 
done display all text!!! -->**it's only show the 1st value in array and then clear the interval**
Lorem ipsum d
Lorem ipsum do


*/
            if(char<TextToDisplay*.length){
                char++;
            }else{
                clearInterval(intervalId);
                onFinished();
            }
        }


so I want the output display all the value before it’s clear the interval… I mean after the last lenght of the value…

here’s all the code.


import CountArrayValueLength;

var DisplayText:Array = ["Lorem ipsum ","Lorem ipsum dolor ","Lorem ipsum dolor sit amet"];

var objTest:CountArrayValueLength = new CountArrayValueLength(DisplayText,10);

objTest.onFinished = function(){
    trace("done display all text!!!");
} 

and my class file



class CountArrayValueLength{
    
    var wait:Number;
    var char:Number;
    var intervalId:Number;
    var onFinished:Function
    var TextToDisplay = new Array();
    
    function CountArrayValueLength(__TextToDisplay:Array, __wait:Number){
        TextToDisplay = __TextToDisplay;
        wait = __wait;
        char = 1;
        init();
    }
    
    function init() {
        intervalId = setInterval(this, "displayAllText", wait);
    }

    function displayAllText(){
        for(var i:Number=0;i<TextToDisplay.length;i++){
            trace(TextToDisplay*.substr(0,char));
            if(char<TextToDisplay*.length){
                char++;
            }else{
                clearInterval(intervalId);
                onFinished();
            }
        }

    }
    
    
}

Hope someone will give shed some light where the hell my wrong is…u’re help are appreciated…thanks in advanced…