setInterval problem, gives the same value over and over to function

LATER EDIT: apparently, I managed to work around it. Anyway, the second setInterval was the one that did not work, and I put instead of:

setInterval(this, “setText”, interval, setAcText());

this:


StratFlash = new setText(setAcText());
setText.prototype.updates = function() {
setText(setAcText())
//  setText(setAcText());
};
setInterval(StratFlash, "updates", 4000);

to the second setInterval…

I have the following code that right now SHOULD do the following:

  • show a different text every 2 seconds
// yay, starting..



/* the below setText creates the text to be shown in the flash and uses the parameter theText as the text */

function setText (theText:String):Void {  
  if(t != null) {t.removeTextField(); }
  if(container != null) { container.removeMovieClip(); }
  
  var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());

  container.createTextField("t", this.getNextHighestDepth(), 30, 30, 150, 20);
  var tf:TextField = container.t;
  tf.text = theText;

}



/* here in function setAcText we declare the texts possible to be shown, and returning one */

var trr = null;
function setAcText():String {
                num = Math.round(Math.random()*3);
                    switch (num) {
                        case 0:    
                            trr = "New Worlds 0"; break ;
                        case 1:
                            trr = "New Worlds 1"; break ;
                        case 2:
                            trr = "New Worlds 2"; break ;
                        case 3:
                            trr = "New Worlds 3"; break ;
                        default:
                            trr = "New Worlds default";
                        }
            return trr;
        }




/* here we set an interval for the function to return a text, then an interval for the other function to construct a movieclip with a textfield to show that text */

var interval = 2000;
setInterval(this, "setAcText", interval)
setInterval(this, "setText", interval, setAcText());



stop();


The problem with it:

  • the setAcText() returns a text, apparently setText grabs it but then it does this only once
  • from my tests I seen that setText actually grabs another text returned from the setAcText, but heh, it still returns something

So, how can I actually make the setText do something, then do something else, then do something else, instead of actually doing the same thing over and over again?

Thank you!