MovieClip.prototype.fadeTo = function(r, g, b, s, _callback, _args) {
var cl = new Color(this);
var tr = cl.getTransform();
for (var i in this) {
if (this[i]._name == "fadeTo_CLP") removeMovieClip(this[i]);
}
var clp = this.createEmptyMovieClip("fadeTo_CLP", this.getNextHighestDepth());
clp.onEnterFrame = function() {
tr.rb += (r - tr.rb) / s;
tr.gb += (g - tr.gb) / s;
tr.bb += (b - tr.bb) / s;
cl.setTransform(tr);
var rs = Math.abs(r - tr.rb);
var gs = Math.abs(g - tr.gb);
var bs = Math.abs(b - tr.bb);
if (rs < 1 && gs < 1 && bs < 1) {
tr.rb = r;
tr.gb = g;
tr.bb = b;
cl.setTransform(tr);
delete this.onEnterFrame;
_callback(_args);
}
}
}
var args = {foo:17, bar:4};
clip.fadeTo(255, -50, -150, 3, onTest, args);
function onTest(args) {
for (var i in args) {
trace(i + " -> " + args[i]);
}
}