Hi guys, good afternoon to you all.
I would like some help if possible.
Ive been working with tween Manager (the laco and robert penner tween proto) and i found simply using the scaleTo function on images which have drop shadows causes distortion. So did some searching and found a resize function which implements the tween manager tween function.
It works well, BUT I would like some help in converting it into a class or prototype , even better build it into tween manager so I can call it like the scaleTo function. I call it frequently for transitions ive created which is why i would like to be able to call it simply
Anyway script is below and ive pasted a fla…Thanks in advance
border = 30;
_swidth = 400;
_sheight = 400;
function init(){
trace(this + "_sheight:"+_sheight);
mcs = [t_mc, b_mc, l_mc, r_mc, tl_mc, tr_mc, bl_mc, br_mc];
//
t_mc._height = border;
b_mc._height = border;
l_mc._width = border;
r_mc._width = border;
//
tl_mc._width = border;
tl_mc._height = border;
tr_mc._width = border;
tr_mc._height = border;
bl_mc._width = border;
bl_mc._height = border;
br_mc._width = border;
br_mc._height = border;
//
setSize(_swidth, _sheight);
}
// sets size
function setSize(width, height) {
var w = width-2*border;
var h = height-2*border;
//
c_mc._width = w;
c_mc._height = h;
//
tr_mc._x = w/2;
tr_mc._y = -h/2;
//
br_mc._x = w/2;
br_mc._y = h/2;
//
bl_mc._x = -w/2;
bl_mc._y = h/2;
//
tl_mc._x = -w/2;
tl_mc._y = -h/2;
//
t_mc._width = w;
t_mc._x = -w/2;
t_mc._y = -h/2;
//
b_mc._width = w;
b_mc._x = -w/2;
b_mc._y = h/2;
//
l_mc._height = h;
l_mc._x = -w/2;
l_mc._y = -h/2;
//
r_mc._height = h;
r_mc._x = w/2;
r_mc._y = -h/2;
}
// sets size with tween
resize_controller = {};
resize_controller.onTweenEnd = function() {
};
resize_controller.onTweenUpdate = function(mc) {
//
var w = Math.floor(c_mc._width);
var h = Math.floor(c_mc._height);
//
tr_mc._x = w/2;
tr_mc._y = -h/2;
//
br_mc._x = w/2;
br_mc._y = h/2;
//
bl_mc._x = -w/2;
bl_mc._y = h/2;
//
tl_mc._x = -w/2;
tl_mc._y = -h/2;
//
t_mc._width = w;
t_mc._x = -w/2;
t_mc._y = -h/2;
//
b_mc._width = w;
b_mc._x = -w/2;
b_mc._y = h/2;
//
l_mc._height = h;
l_mc._x = -w/2;
l_mc._y = -h/2;
//
r_mc._height = h;
r_mc._x = w/2;
r_mc._y = -h/2;
};
c_mc.addListener(resize_controller);
//----------------------------------------------------
color_controller = {};
color_controller.onTweenUpdate = function() {
var ct = this.color.getTransform();
for (var i in clrs) {
clrs*.setTransform(ct);
}
};
var clrs = [];
for (var i in mcs) {
clrs* = new Color(mcs*.gr);
}
color_controller.clrs = clrs;
color_controller.color = new Color(c_mc);
c_mc.addListener(color_controller)
//---------------------------------------------------- public functions
function resizeTo(width, height, dur, style, delay, callback) {
trace("resize in "+this+" called");
c_mc.tween(['_width', '_height'], [width-2*border+9, height-2*border+9], dur, style, delay, callback);
}
function tintTo(clr, dur, style, delay, callback) {
c_mc.colorTo(clr, dur, style, delay, callback);
}
init();