# EnterFrame Madness

**URL:** <https://forum.kirupa.com/t/enterframe-madness/79715>\
**Category:** Uncategorized\
**Created:** [February 16, 2005, 3:48pm UTC](https://forum.kirupa.com/t/enterframe-madness/79715 "2005-02-16T15:48:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![exorxist](https://avatars.discourse-cdn.com/v4/letter/e/f4b2a3/32.png) [@exorxist](https://forum.kirupa.com/u/exorxist)\
**Post date:** [February 16, 2005, 3:48pm UTC](https://forum.kirupa.com/t/enterframe-madness/79715/1 "2005-02-16T15:48:10Z")

</div>

Hi. Question for anyone out there that can help. I have a whole bunch of onClipEvent(enterFrame){} events going on. Would taking all that code and putting it into just one mc’s onClipEvent(enterFrame){} function lower cpu usage?

What is a good way to have enterFrame functions die if not needed? I can post my code if anyone wants to take a look.

I can give a quick overview:

I have 5 nav buttons. The first two have sub sections. (1st one has 2 elements, 2nd one has 4 elements). The way I set it up, each of these buttons checks on the \_y position of the button below it. I then use a move function with inertia to move the bottom button, and all buttons on top of move along with a springy feel. Also, when these move, I show the 2nd frame of each of the buttons in the corresponding section, for it shows the text of each button.

This is the way I am doing it right now (By setting everything in one enter frame function it seems to run a lot smoother than when each element had its own enterframe function for just one line of code):

```auto

onClipEvent (enterFrame) {
	_parent.link1_1._y = _parent.link1_2._y-20;
	_parent.link1_2._y = _parent.link1_3._y-7;
	_parent.link2_1._y = _parent.link2_2._y-20;
	_parent.link2_2._y = _parent.link2_3._y-20;
	_parent.link2_3._y = _parent.link2_4._y-20;
	_parent.link2_4._y = _parent.link2_5._y-7;
	_parent.link3._y = _parent.link3_2._y-7;
	_parent.link4._y = _parent.link4_2._y-7;
	_parent.link5._y = _parent.link5_2._y-7;
	if (_root._xmouse>=285 && _root._xmouse<=378 && _root._ymouse>=490 && _root._ymouse<=600) {
		_root.link1_1.gotoAndStop(2);
		_root.link1_2.gotoAndStop(2);
		_root.link1_3.move(331, 577, 0.5, 0.2);
	} else {
		_root.link1_1.gotoAndStop(1);
		_root.link1_2.gotoAndStop(1);
		_root.link1_3.move(331, 604, 0.5, 0.2);
	}
	if (_root._xmouse>=381 && _root._xmouse<=475 && _root._ymouse>=490 && _root._ymouse<=600) {
		_root.link2_1.gotoAndStop(2);
		_root.link2_2.gotoAndStop(2);
		_root.link2_3.gotoAndStop(2);
		_root.link2_4.gotoAndStop(2);
		_root.link2_5.move(428, 577, 0.4, 0.2);
	} else {
		_root.link2_1.gotoAndStop(1);
		_root.link2_2.gotoAndStop(1);
		_root.link2_3.gotoAndStop(1);
		_root.link2_4.gotoAndStop(1);
		_root.link2_5.move(428, 644, 0.4, 0.2);
	}
	if (_root._xmouse>=476 && _root._xmouse<=572 && _root._ymouse>=490 && _root._ymouse<=600) {
		_root.link3.gotoAndStop(2);
		_root.link3_2.move(525, 577, 0.6, 0.2);
	} else {
		_root.link3.gotoAndStop(1);
		_root.link3_2.move(525, 584, 0.6, 0.2);
	}
	if (_root._xmouse>=576 && _root._xmouse<=672 && _root._ymouse>=490 && _root._ymouse<=600) {
		_root.link4.gotoAndStop(2);
		_root.link4_2.move(622, 577, 0.6, 0.2);
	} else {
		_root.link4.gotoAndStop(1);
		_root.link4_2.move(622, 584, 0.6, 0.2);
	}
	if (_root._xmouse>=674 && _root._xmouse<=770 && _root._ymouse>=490 && _root._ymouse<=600) {
		_root.link5.gotoAndStop(2);
		_root.link5_2.move(719, 577, 0.6, 0.2);
	} else {
		_root.link5.gotoAndStop(1);
		_root.link5_2.move(719, 584, 0.6, 0.2);
	}
}

```

I would really appreciate any input. Thanks!
