[ascoders] Group 94 Text Effect

  • From: "Peter Oliver Geller" <nc-gellerpe@xxxxxxxxxxxxx>
  • To: <ascoders@xxxxxxxxxxxxx>
  • Date: Tue, 1 Jul 2003 12:42:08 +0200

//#initclip
_global.textBox = function() {
        // setup text format objects
        this.in_fmt = new TextFormat();
        this.out_fmt = new TextFormat();
        this.in_fmt.color = 0xFFFFFF;
        this.out_fmt.color = 0xCCCCCC;
};
Hallo nochmal,
vielleicht kennt einer von euch diesen Texteffect,
allerdings habe ich hier eine Frage.
Kann man in einer Klasse statt this.onEnterFrame einen interval Aufruf
ausführen der in der Klasse gestartet wird und
die this verweise auch noch funktionieren?
Ich habe nämlich alles mögliche Versucht und bin erstmal gescheitert.
Vielleicht hatte ja schonmal einer von euch das Problem?
 
Object.registerClass("textBox", textBox);
textBox.prototype = new MovieClip();
// replaces current text with new text.
// new text comes in a word at a time, old text is removed
// at same rate as new text comes in.
textBox.prototype.setText = function(newText) {
        this.oldText = this._txt.text;
        // find out how long the text is..
        this.oti = this.oldText.length;
        // buffer for new text coming into the text box
        this.incomingText = "";
        // make array of words..
        this._ta = newText.split(" ");
        // calculate how many letters to remove each frame
        this.removeCount = Math.round(this.oti/this._ta.length);
        if (this.removeCount<1) {
                this.removeCount = 1;
        }
        this.onEnterFrame = function() {
                if (this.oti>0) {
                        var ot = this.oldText.substring(0, this.oti -=
this.removeCount);
                } else {
                        var startDone = true;
                }
                if (this._ta.length) {
                        this.incomingText = this._ta.pop()+"
"+this.incomingText;
                } else {
                        var endDone = true;
                }
                if (startDone && endDone) {
                        delete this.onEnterFrame;
                }
                var itl = this.incomingText.length;
                var tl = itl+ot.length;
                this._txt.text = this.incomingText+ot;
                this._txt.setTextFormat(0, itl, this.in_fmt);
                this._txt.setTextFormat(itl, tl, this.out_fmt);
        };
};
//#endinitclip

Peter

::::::::::::::::::::::::::::::::::::::::::::::
Peter Oliver Geller
(design / development)

www.pixel-gallery.net
::::::::::::::::::::::::::::::::::::::::::::::

Other related posts: