Marquee

Wrote up a quick function to do a marquee in actionScript.
[swf=http://yeldarb.servehttp.com/misc/marquee.swf]width=524 height=114.6[/swf]


    myText = "Testing Testing 123 Hahaha, It works!  Yay!";
    scrollIt(myText, 0xFFFFFF, 4, 30, 500, 3);
    function scrollIt(textToWrite, theColor, x, y, width, speed) {
        this.createEmptyMovieClip("marquee", 1);
    
        marquee._x = x;
        marquee._y = y;
        
        marquee.createEmptyMovieClip("theText", 2);
        marquee.theText._x = 15;
        marquee.theText._y = 1;
        marquee.theText.theWidth = Math.round(textToWrite.length * 8) + 5;
        marquee.theText.createTextField("theTip", 0, 0, -1, marquee.theText.theWidth, 22);
        marquee.theText.formatIt = new TextFormat;
        marquee.theText.formatIt.font = "Times New Roman";
        marquee.theText.formatIt.align = "center";
        marquee.theText.formatIt.color = theColor;
        marquee.theText.formatIt.size = 16;
        marquee.theText.theTip.text = textToWrite;
        marquee.theText.theTip.setTextFormat(marquee.theText.formatIt);
        
        //textFieldWidth = theText._width + 10;
        marquee.theTextFieldWidth = marquee.theText.theTip._width + 10;
        
        marquee.createEmptyMovieClip("backgroundBox", 1);
        //marquee.backgroundBox.lineStyle(1, 0xCCCCCC, 100);
        marquee.backgroundBox.moveTo(10, 0);
        marquee.backgroundBox.beginFill(0x444444, 10);
        marquee.backgroundBox.moveToHere = width;
        marquee.backgroundBox.lineTo(marquee.backgroundBox.moveToHere, 0);
        marquee.backgroundBox.lineTo(marquee.backgroundBox.moveToHere, 22);
        marquee.backgroundBox.lineTo(10, 22);
        marquee.backgroundBox.lineTo(10, 0);
        marquee.backgroundBox.endFill();
        
        marquee.theText.setMask(marquee.backgroundBox);
        
        marquee.theText._x = width;
        marquee.theText.returnTo = width;
        
        marquee.theText.onEnterFrame = function() {
            returnX = 0 - this._width;
            if(this._x > returnX) {
                this._x -= speed;
            } else {
                this._x = this.returnTo;
            }
        }
    }