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();
            }
        }
    };
};




deconstruct String prototype       ½  

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

Prototipo "made by drus", este efecto de texto deconstruye una cadena en palabras y contruye parrafos de acuerdo al tamaño deseado.
El hecho de deconstruir permite aplicar efectos a cada palabra.

Actionscript:
mytext = 'Lorem ipsum te pro utinam volutpat. An mundi putant eam, nam ad soluta aliquid cotidieque, no nam nominavi repudiandae. Eum ne vero accusam expetenda. Velit takimata consulatu no eos';
//
String.prototype.deconstruct = function(mc, ancho) {
    var words:Array = new Array();
    var words = this.split(" ");
    var espaciado = 5;
    var interlineado = 20;
    var column = ancho;
    var n = 0;
    for (var i=0; i<words .length; i++) {
        var word:MovieClip = mc.createEmptyMovieClip("word_el"+i, i);
        if (i>0) {
            mix += mc["word_el"+(i-1)]._width+espaciado;
        } else {
            var mix = 0;
        }
        if (mix>column) {
            var mix = 0;
            n++;
            var miy = n*interlineado;
        }
        word._x = mix;
        word._y = miy;
        word.createTextField("field", i, 0, 0, 4, 4);
        word.field.autoSize = "left";
        word.field.border = false;
        word.field.selectable = false;
        word.field.text = words[i];
    }
};
//Uso
_root.createEmptyMovieClip("parrafo",1);
mytext1.deconstruct(parrafo, 150);




standardToBold String prototype          

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

Prototipo "made by drus", efecto de texto creado para aplicar negritas en fuentes pixeladas como la standard.
Debemos tener las fuentes linkadas en la librería.

Actionscript:
String.prototype.toBold = function() {
    var tmp_txt:String=this.split("<b>").join("<font face='bold'>");
    tmp_txt=tmp_txt.split("</b>").join("</font>");
    return tmp_txt;
};
mytext = "<b>Lorem ipsum dolor sit amet</b>, consectetuer adipiscing elit. In <b>sagittis</b> quam et nibh. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras adipiscing iaculis orci. Suspendisse potenti. In elementum varius nunc. Proin accumsan arcu et massa. Quisque eu eros in turpis molestie dapibus. Aliquam erat volutpat. Donec erat purus, tristique congue, pretium vitae, volutpat eu, justo. Phasellus porttitor. Etiam et metus nec nunc egestas euismod. Suspendisse a purus. Proin laoreet leo at enim. Quisque risus. Vivamus pede. Duis quis velit. Quisque in urna. <b>Fusce elementum</b> diam vitae tellus. Vestibulum vehicula dui sed tellus.";
//Uso
txt.htmlText=mytext.toBold();

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



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