Este prototipo pasa a blanco y negro el movieClip sobre el que se aplica. La primera versión sencillamente desatura, y la segunda crea un duplicado sobre el mc original para tener disponible el item original en color, para por ejemplo un rollOver ;)
Actionscript:
import flash.filters.ColorMatrixFilter;
MovieClip.prototype.desaturate = function():Void {
var bn_filter:ColorMatrixFilter = new ColorMatrixFilter([0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0, 0, 0, 1, 0]);
this.filters = [bn_filter];
};
//Uso:
mc.desaturate();
Actionscript:
import flash.filters.ColorMatrixFilter;
MovieClip.prototype.desaturateAndDuplicate = function():Void {
var bn_filter:ColorMatrixFilter = new ColorMatrixFilter([0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0, 0, 0, 1, 0]);
var bmp = new flash.display.BitmapData(this._width, this._height, true, 0x00000000);
var bn:MovieClip = this._parent.createEmptyMovieClip("bn_mc", 2);
bn.attachBitmap(bmp,0);
bmp.draw(this);
bn.filters = [bn_filter];
this._visible = false;
};
//Uso:
mc.desaturateAndDuplicate();
Imprescindible haber importado el filtro ColorMatrixFilter.
Este prototipo crea un efecto de reflejo del movieClip sobre el que se aplica, duplicandolo, volteandolo y aplicándole un degradado lineal que lo funde sobre un fondo blanco.
Desgraciadamente, si la imagen es cargada dinámicamente, también hay que cargarla en el duplicado, ya que se duplica el movieClip en su estado inicial (shit!).
Actionscript:
//http:drusunlimited.com
MovieClip.prototype.reflex = function() {
var reflejo:MovieClip = this.duplicateMovieClip(this._name+"reflejo", this.getDepth()+100);
reflejo._yscale = -100;
reflejo._y = this._y+this._height*2;
var degrade:MovieClip = reflejo.createEmptyMovieClip("degrade_mc", 1);
degrade.fillType = "linear";
degrade.colors = [0xFFFFFF, 0xFFFFFF];
degrade.alphas = [100, 80];
degrade.ratios = [150, 255];
degrade.matrix = {matrixType:"box", x:0, y:0, w:this._width, h:this._height, r:90/180*Math.PI};
with (degrade) {
beginGradientFill(fillType, colors, alphas, ratios, matrix);
lineStyle(5, 0xFF00FF, 0);
moveTo(0, 0);
lineTo(this._width, 0);
lineTo(this._width, this._height);
lineTo(0, this._height);
moveTo(0, 0);
endFill();
}
};
//Uso:
obj_mc.reflex();
Enlaces relacionados: No related posts, | Tags:
actionscript,
prototipo,
efecto,
MovieClip
Este prototipo permite realizar transiciones avanzadas de color, creando el efecto de foto quemada.
Actionscript:
MovieClip.prototype.picBurner = function(sentido:String) {
this.onEnterFrame = function() {
if (sentido == "out") {
if (this.n == undefined) {
this.n = 0;
}
if (this.n<256) {
this.n += 10;
} else {
delete this.onEnterFrame;
}
} else {
if (this.n == undefined) {
this.n = 256;
}
if (this.n>0) {
this.n -= 10;
} else {
delete this.onEnterFrame;
}
}
thisColor = {ra:100, rb:this.n, ga:100, gb:this.n, ba:100, bb:this.n, aa:256-this.n, ab:0};
col = new Color(this);
col.setTransform(thisColor);
};
};
//Uso
foto.picBurner("out");
foto2.picBurner("in");
Enlaces relacionados: No related posts, | Tags:
actionscript,
prototipo,
efecto,
MovieClip
Genera un temblor en la cantidad definida por el parámetro value. Si se usa sin parámetros detiene el temblor.
Actionscript:
MovieClip.prototype.shake = function(value) {
if (value) {
this.orgX = this._x;
this.orgY = this._y;
this.onEnterFrame = function() {
this._x = this.orgX+Math.random()*(value*2)-value;
this._y = this.orgY+Math.random()*(value*2)-value;
};
} else {
delete this.onEnterFrame;
this._x = this.orgX;
this._y = this.orgY;
}
};
//Uso 1
obj_mc.shake(5);//provoca un temblor de 5 pixeles
//Uso 2
obj_mc.shake();//detiene temblor
Enlaces relacionados: No related posts, | Tags:
actionscript,
prototipo,
efecto,
comportamiento,
shake,
MovieClip
Prototipo "made by drus" para hacer parpadear un movieClip.
Actionscript:
MovieClip.prototype.blink = function(veces, vel, fin) {
obj = this;
obj.n = obj._visible;
obj.cont = 0;
vel == undefined ? obj.vel=100 : obj.vel=vel;
this.id = setInterval(function () {
obj.cont += 1;
if (obj.cont<=veces*2) {
obj._visible = !obj._visible;
} else {
if (fin == undefined) {
fin = true;
}
obj._visible = fin;
clearInterval(obj.id);
}
}, this.vel);
};
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();
}
}
};
};
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);
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:
actionscript,
prototipo,
efecto,
texto,
String
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:
actionscript,
prototipo,
efecto,
texto,
TextField
Prototipo de Kaax, publicado generosamente en After-hours
Actionscript:
import flash.filters.BlurFilter;
MovieClip.prototype.blurTo = function(x, y, speed, blurX, blurY, calidadBlur) {
this.onEnterFrame = function() {
if (Math.round(this._x) == Math.round(x) && Math.round(this._y) == Math.round(y)) {
blurToParando = new BlurFilter(0, 0, 0);
this._x = Math.round(this._x);
this._y = Math.round(this._y);
this.filters = [blurToParando];
delete this.onEnterFrame;
} else {
blurTo = new BlurFilter(blurX--, blurY--, calidadBlur);
this._x -= (this._x-x)*speed;
this._y -= (this._y-y)*speed;
this.filters = [blurTo];
}
};
};
//Uso:
mc.blurTo(523, 434, .1, 50, 50, 4);
Enlaces relacionados: No related posts, | Tags:
actionscript,
prototipo,
efecto,
blur,
MovieClip
—
Siguiente página »