# \[FMX\] Function problem

**URL:** <https://forum.kirupa.com/t/fmx-function-problem/106921>\
**Category:** Uncategorized\
**Created:** [April 10, 2004, 7:19am UTC](https://forum.kirupa.com/t/fmx-function-problem/106921 "2004-04-10T07:19:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)\
**Post date:** [April 10, 2004, 7:19am UTC](https://forum.kirupa.com/t/fmx-function-problem/106921/1 "2004-04-10T07:19:51Z")

</div>

Hi,

I have a problem with a email form. I have made an email form. I made two functions to control the forms background and btn\_close and mc\_titels. This is the code I have:

```auto
function scaleClip (clip, wijd, hoog, speed){
clip.onEnterFrame = function(){
	var wdiff = wijd-this._width;
	this._width += wdiff/speed;
	var hdiff = hoog-this._height;
	this._height += hdiff/speed;
	if (Math.abs(wdiff)<1 && Math.abs(hdiff)<1) {
	fadeClip ([mc_titels, btn_close], 100, 4);
	delete this.onEnterFrame;
	}
}
}
function fadeClip (clips, fade, speed){
//loop: bekijkt de groote van de array
while (clips.length){
// mc's hebben verschillende namen
clips[0].onEnterFrame = function(){
var fadeOut = fade - this._alpha;
this._alpha += fadeOut /speed;
};
clips.splice(0, 1);
}
}
scaleClip (mc_background, 253, 156, 4); 
 
btn_close.onRelease = function(){
scaleClip (mc_background, 0, 0, 3);
fadeClip ([this, mc_titels], 0, 6);
}

```

The scaleClip function is ment to control the form background. The fadeClip is to control btn\_close and the form titles. Everything is working fine so far.

The scaleClip function callback makes the background scale to the right width an height and the fadeClip call back within the scaleClip function is also working because after mc\_background reaches it’s final width and height btn\_close button and mc\_titels are fading in.

So still no problems so far, but when I press the btn\_close button things are going wrong. The scaleClip is working fine, but with the fadeClip function connected to btn\_close something is going wrong. After btn\_close and mc\_titels are faded out completely they are fading back in again. I really don’t see what I’m doing wrong. Is there somebody who see a mistake in the script?

Thanks in advance
