# What is wrong with this code?

**URL:** <https://forum.kirupa.com/t/what-is-wrong-with-this-code/132632>\
**Category:** Uncategorized\
**Created:** [December 30, 2004, 5:37pm UTC](https://forum.kirupa.com/t/what-is-wrong-with-this-code/132632 "2004-12-30T17:37:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiliaan856](https://avatars.discourse-cdn.com/v4/letter/k/67e7ee/32.png) [@kiliaan856](https://forum.kirupa.com/u/kiliaan856)\
**Post date:** [December 30, 2004, 5:37pm UTC](https://forum.kirupa.com/t/what-is-wrong-with-this-code/132632/1 "2004-12-30T17:37:04Z")

</div>

I started a previous thread that was just too vague, wasn’t near my comptuer and I thought if I understood the concepts a little better I could work this out. Here is the problem, I am having a hard time understanding how to attach this function to a movieclip in a meaningful way, this is my code. Hopefully someone can shed some light on my errors. All of this code resides in \_level0 frame 1.

```auto

   effect = function(scale) {
   	currentFrame = 0;
   	this.onEnterFrame = function() {
 		this.speedXscale = (this.speedXscale*this.friction)+((scale-this._xscale)*this.ratio);
 		this.speedYscale = (this.speedYscale*this.friction)+((scale-this._yscale)*this.ratio);
   		this._xscale += this.speedXscale;
   		this._yscale += this.speedYscale;
   		currentFrame++;
   		if (Math.floor(this._xscale*100) == (scale*100)) {
   			delete this.onEnterFrame;
   		}
   	}
   }
   
   
   ... elsewhere ...
   //effect code (bounce)
 //
 this.menu[context+"_"+optionnumber].friction = .8;
 this.menu[context+"_"+optionnumber].ratio = .3;
 this.menu[context+"_"+optionnumber].speedXscale = 0;
 this.menu[context+"_"+optionnumber].speedYscale = 0;
 this.menu[context+"_"+optionnumber].optionEffect = new effect();
 // option events
 
 this.menu[context+"_"+optionnumber].onRollOver = function() {
 	optionEffect(200);
 }
 this.menu[context+"_"+optionnumber].onRollOut = function() {
 	optionEffect(100);
 }
   
   

```

Thanks!
