Wednesday, March 4, 2009

Flash - Old School Actionscript Tweening

ON the MovieClip itself

/* */
onClipEvent(load) {
mytime = _parent.timeSlower;
mybounce = _parent.bounceSlower;
}
onClipEvent (load) {
physics = [mybounce,mytime];
start_x = this._x;
start_y = this._y;
start_w = this._width;
start_h = this._height;
start_xscale = this._xscale;
start_yscale = this._yscale;
start_a = this._alpha;

xspeed = 0;
yspeed = 0;
aspeed = 0;
wspeed = 0;
hspeed = 0;
xscalespeed = 0;

//this._width = (this._width*1.2);
//this._height = (this._height*1.2);

//this._width = this._width/2;
}
onClipEvent (enterFrame) {
xscalespeed = ((start_xscalespeed-this._xscale)*physics[0])+(xscalespeed*physics[1]);
this._xscale += xscalespeed;

yscalespeed = ((start_yscalespeed-this._yscale)*physics[0])+(yscalespeed*physics[1]);
this._yscale += yscalespeed;

wspeed = ((start_w-this._width)*physics[0])+(wspeed*physics[1]);
this._width += wspeed;

hspeed = ((start_h-this._height)*physics[0])+(hspeed*physics[1]);
this._height += hspeed;

xspeed = ((start_x-this._x)*physics[0])+(xspeed*physics[1]);
this._x += xspeed;
yspeed = ((start_y-this._y)*physics[0])+(yspeed*physics[1]);
this._y += yspeed;
aspeed = ((start_a-this._alpha)*physics[0])+(aspeed*physics[1]);
this._alpha += aspeed;
}
/**/

Still need to establish the "time" and "bounce" variables for consistency across the board.