# Help with SetInterval / delete onEnterFrame

**URL:** https://forum.kirupa.com/t/help-with-setinterval-delete-onenterframe/257000
**Category:** Uncategorized
**Created:** [April 9, 2008, 12:47pm UTC](https://forum.kirupa.com/t/help-with-setinterval-delete-onenterframe/257000 "2008-04-09T12:47:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![iaineach](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@iaineach](https://forum.kirupa.com/u/iaineach)
#### Post date: [April 9, 2008, 12:47pm UTC](https://forum.kirupa.com/t/help-with-setinterval-delete-onenterframe/257000/1 "2008-04-09T12:47:40Z")

</div>

Hi,

Having some difficulty removing an onEnterFrame function for a scaling effect on a map. If I don’t remove it, the function seems to loop, causing massive resource usage and slowing down the HTML page its on.

What I want to do is let the function happen when a button is clicked, then for it to stop once its scaled once. The function has to be called from a zoom in, zoom out and a reset button.

I have the basic code below, but this isn’t working. Any help would be greatly appreciated.

```auto
 
//the zoom in button actions
zoomIn_btn.onPress = function() {
 clearInterval(zoomInterval);
 zoomInterval = setInterval(_root, "zoomIn", 100);
 zoomIn();
 nicescale();
};
//the scaling effect
function nicescale() {
 map_mc.onEnterFrame = function() {
  this._xscale = this._yscale += (this.scale-this._xscale)/2;
  if (this.activeMovement) {
   this._x += (this.x-this._x)/2;
   this._y += (this.y-this._y)/2;
  }
 };
};
//remove the scaling effect
function removescale() {
 delete map_mc.onEnterFrame;
 scaleInterval = setInterval(_root, "scaleInterval", 100);
}

```

I know I need to call the ‘removescale’ function, but at the moment it’s not working so I’ve removed it from the zoomIn\_btn.onPress function.

cheers,  
iain
