Adding Easing Tween -- to exisiting function

Adding Easing Tween – to exisiting function

Ok so I found this nice code over at Prototype. Its a function for Aligning to stage on Resize. http://proto.layer51.com/d.aspx?f=1514

It works really nice on its own but I was hoping to add some tweened easing as an additional optional parameter. (I posted there twice asking for help to no avail =( So I am asking here at Kirupa, hoping someone can help me with my struggles. What I wish to add is - implementing and adding an “easing” function as part of the current function. Something generalized to be called only if desired and the ability to set the ease type, duration, maybe prop etc… (or whatever needed to make it work :*( )

I have tried all kinds of things and below is as close as I can come (at least the only thing I can do to get the thing to move, although as you will see it works backwards and I can only get it to work using stage.width, stage.height, however I have tried newX oldX and all kinds of other things and cant seem to get things to move.

I am missing something, perhaps everything :hugegrin:

// Original Script found here --
// Functions: Align to stage on Resize --  [http://proto.layer51.com/d.aspx?f=1514](http://proto.layer51.com/d.aspx?f=1514)

// +++ Stage Align +++
// onR function is used with fullscreen & "T(op)L(eft)" Stage.align as a ref point!!!
//fscommand( "fullscreen", true ); // <<-- Optional if needed

import mx.transitions.Tween;
import mx.transitions.easing.*;
Stage.scaleMode = "noScale";
Stage.align = "TL";

**// Optional Easing -- I am trying to add with no success =(**

function mover(obj:MovieClip, startX:Number, startY:Number, endX:Number, endY:Number) {
	var tweenX:Tween = new Tween(obj, "_x", Regular.easeInOut, startX, endX, 1, true);
	var tweenY:Tween = new Tween(obj, "_y", Regular.easeInOut, startY, endY, 1, true);
}

// trigger alignment via Stage listener object!
// alignment options: "TL", "TR", "TC", "BL", "BR", "BC", "CL", "CR", "CC"
// optional offset by X or Y axis provided as an object property: obj.X, obj.Y

function onR(A, obj) {
	var F = String(A).substring(0, 1);
	var L = String(A).substring(1, 2);
	(obj.X == undefined) ? obj.X=0 : obj.X=obj.X;
	(obj.Y == undefined) ? obj.Y=0 : obj.Y=obj.Y;
	if (F == "T") {
		obj._y = Math.ceil(obj.Y);
	} else if (F == "B") {
		obj._y = Math.ceil(Stage.height-obj._height-obj.Y);
	} else if (F == "C") {
		obj._y = Math.ceil((Stage.height-obj._height)/2-obj.Y);
	}
	if (L == "L") {
		obj._x = Math.ceil(obj.X);
	} else if (L == "R") {
		obj._x = Math.ceil(Stage.width-obj._width-obj.X);
	} else if (L == "C") {
		obj._x = Math.ceil((Stage.width-obj._width)/2-obj.X);
	}
}
//Usage
// ... later 
// -- OPTIONAL positioning - to add further positioning of items if needed

mc_1.X = 100;
// X offset for mc_1 used for Center Left alignment
mc_2.Y = -50;

// Y offset for mc_2 used for Center Right alignment

var resizeListener:Object = new Object();
resizeListener.onResize = function() {
	onR("CL", mc_1);
	onR("CR", mc_2);

**// Optional Easing Call to mover function -- I am trying to add with no success =(**
// I know its set to stage center now but with all my efforts, this is the only senerio
// I can get anything to move, I tried newX old X etc.. this. and on and on.. can
// someone be so kind to help me add an "optional" workable easing function to this
// script? Mucho Apreciato to anyone that does ;-)

	mover(mc_1, mc_1._x, mc_1._y, Math.round(Stage.width/2), Math.round(Stage.height/2));
	mover(mc_2, mc_2._x, mc_2._y, Math.round(Stage.width/2), Math.round(Stage.height/2));
};
Stage.addListener(resizeListener);

// also the 2 mcs have registration in upper left etc..

I am open to suggestions on implementation, I just thought this function from prototype was pretty slick really and wanted to add some easing to it. It should be possible, I just cant get my head wrapped around it. :h:

Can anyone please provide some help? I really appreciate your input people Thanks for your help.


Simplify What I am asking:

http://proto.layer51.com/d.aspx?f=1514

Add easing to the above function found at that link (also posted above) on browser resize, so any MCs using the align function ease to there new location instead of just snapping into place.

Thanks everyone =)