# Tweening Function repeating

**URL:** <https://forum.kirupa.com/t/tweening-function-repeating/82655>\
**Category:** flash\
**Created:** [March 12, 2005, 12:27am UTC](https://forum.kirupa.com/t/tweening-function-repeating/82655 "2005-03-12T00:27:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![murmur](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@murmur](https://forum.kirupa.com/u/murmur)\
**Post date:** [March 12, 2005, 12:27am UTC](https://forum.kirupa.com/t/tweening-function-repeating/82655/1 "2005-03-12T00:27:19Z")

</div>

Hey, It’s my first time posting on this form so please excuse any policy oversight.

I’m having some major problems. With the mx.transitions class.

I have a Function that tweens the alpha of a movie clip to 0, then when that is complete, tweens the alpha back to 100. The problem is when i click the button more than once, before the tween is complete, it runs the tweening function several times in tandem.

Below is the code and the source/swf can be viewed here: [http://www.unidentifiedmedia.com/fla/](http://www.unidentifiedmedia.com/fla/)

Thanks for your help!  
Brandon

```auto
stop();
var oldImgWidth = "";
var oldImgHeight = "";
var newImgWidth = "";
var newImgHeight = "";
var oldImgX = "";
var newImgX = "";
// TWEEN THE ALPHA LEVEL OF THE ULOADING MOVIE CLIP
var proto_object = new Object();
proto_object.fntween = function(oldImgWidth, oldImgHeight, newImgWidth, newImgHeight, oldImgX, newImgX, img_arg) {
	img_mc_alphaDown = new mx.transitions.Tween(container_mc, "_alpha", mx.transitions.easing.Strong.easeIn, 100, 0, 0.5, true);
	img_mc_alphaDown.onMotionFinished = function() {
		//trace(img_mc_alphaDown)
		easeType = mx.transitions.easing.Strong.easeOut;
		var time = .7;
		imgContTweenWidth = new mx.transitions.Tween(container_mc, "_width", easeType, oldImgWidth, newImgWidth, time, true);
		imgContTweenHeight = new mx.transitions.Tween(container_mc, "_height", easeType, oldImgHeight, newImgHeight, time, true);
		imgContTweenX = new mx.transitions.Tween(container_mc, "_x", easeType, oldImgX, newImgX, time, true);
		imgContTweenHeight.onMotionFinished = function() {
			trace("tweenImgContainer Finished");
			img_mc_alphaUp = new mx.transitions.Tween(container_mc, "_alpha", mx.transitions.easing.Strong.easeIn, 0, 100, 0.5, true);
			img_mc_alphaUp.onMotionFinished = function() {
				trace("tweenImgAlphaUp Finished");
			};
		};
	};
};
btn_mc.onRelease = function() {
	delete tween_object;
	//tween_object.img_mc_alphaDown
	var tween_object = proto_object.fntween;

	newImgWidth = (int(this._parent._parent.xmlArray[currentIMG_array].imgWidth)+5);
	newImgHeight = (int(this._parent._parent.xmlArray[currentIMG_array].imgHeight)+5);
	oldImgX = container_mc._x;
	newImgX = ((bar_mc._width-newImgWidth)/2);
	oldImgWidth = container_mc._width;
	oldImgHeight = container_mc._height;
	tween_object(oldImgWidth, oldImgHeight, newImgWidth, newImgHeight, oldImgX, newImgX, img_arg);
};

```
