flipTo TextField prototype          

Clasificado bajo: AS2 (deprecated), Prototipos, String — drus @ 12:30 am

Prototipo extraido de layer51 y modificado para admitir etiquetas HTML.
Imita el estupendo efecto de texto de group94 de construcción de texto letra a letra, con variaciones aleatorias.

Actionscript:
TextField.prototype.flipTo = function(s, rot) {
    if (s == undefined) {
        s = "";
    }
    if (this.text == "") {
        this.text = " ";
    }
    var T = this._parent.createEmptyMovieClip(this._name+"_typer", this._parent.getNextHighestDepth());
    T.txt = s;
    T.rot = rot == undefined ? 0 : rot;
    T.targ = this;
    T.oldtxt = this.text;
    for (var i = 0; i<T.oldtxt.length; i++) {
        if (T.oldtxt.charAt(i) != T.txt.charAt(i)) {
            T.backto = i;
            break;
        }
    }
    T.dir = -1;
    T.count = 0;
    T.onEnterFrame = function() {
        if (this.L == undefined) {
            this.L = this.targ.text.length;
        }
        if (++this.count>this.rot) {
            this.L = this.L+T.dir;
            this.count = 0;
        }
        var rndchar = chr(48+Math.random()*74);
        if (this.dir<1) {
            if (this.L>T.backto) {
                this.targ.htmlText = this.targ.text.substr(0, this.L-1)+rndchar;
            } else {
                this.dir = 1;
            }
        } else {
            if (this.L<=this.txt.length) {
                if (this.txt.charAt(this.L-1) == "<") {
                    var LT = this.L;
                    for (var i = 0; i<this.txt.length; i++) {
                        if (this.txt.charAt(i) == ">") {
                            this.L = i+1;
                            var tmp = this.txt.substr(0, this.L);
                            this.targ.htmlText = tmp;
                            break;
                        }
                    }
                    this.targ.htmlText = this.txt.substr(0, this.L-1);
                } else {
                    this.targ.htmlText = this.txt.substr(0, this.L-1)+rndchar;
                }
            } else {
                this.targ.htmlText = this.txt;
                this.onEnterFrame = undefined;
                this.removeMovieClip();
            }
        }
    };
};




textoFx TextField prototype     ½    

Clasificado bajo: AS2 (deprecated), Prototipos, String — drus @ 12:04 am

Prototipo para recrear el efecto de texto de group94 en el que van apareciendo los carácteres de la cadena input desde el último al primero.
Publicado en After-hours

Actionscript:
TextField.prototype.textoFx = function(input){
   var obj = this;
   obj.htmlText = "";
   var mi_level = random(500)+500;
   var mc = this._parent.createEmptyMovieClip("loop", mi_level);
   var input = String(input).split(" ");
   mc.onEnterFrame = function() {
      obj.htmlText = input.pop()+" "+obj.htmlText;
      if (!input.length) {
         delete mc.onEnterFrame;
         removeMovieClip(mc);

      }
   };
};
//Uso
textarea.textoFx("Nulla ac justo. Integer mauris. Aliquam consectetuer libero at nulla. Phasellus at purus vitae nisi porttitor aliquam. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec dignissim tellus imperdiet lorem. Nunc hendrerit consectetuer elit. Donec ullamcorper orci. In pellentesque, neque pellentesque porta consectetuer, dui odio venenatis orci, id vulputate arcu dui vel mauris. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum eget nibh non ipsum tempus consectetuer.");

Enlaces relacionados: No related posts, | Tags: , , , ,



Siguiente página »

AS_toolKit | Powered by WordPress | Skinned by Drus Unlimited | RSS Feed | Copyleft