# Problems with On and OnClipEvent

**URL:** <https://forum.kirupa.com/t/problems-with-on-and-onclipevent/117137>\
**Category:** Uncategorized\
**Created:** [July 24, 2004, 8:01pm UTC](https://forum.kirupa.com/t/problems-with-on-and-onclipevent/117137 "2004-07-24T20:01:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![darkstyle](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@darkstyle](https://forum.kirupa.com/u/darkstyle)\
**Post date:** [July 24, 2004, 8:01pm UTC](https://forum.kirupa.com/t/problems-with-on-and-onclipevent/117137/1 "2004-07-24T20:01:38Z")

</div>

i have an actionscript in a movie to make the movie play at a certain frame. there’s 3 stop points. for rolling out, rolling over, and releasing the button. I also have an onclipevent(enterframe) which also executes a code to make the movie play at a certain frame. But for some reason the enterframe actionscript seems to mess with the on(rollOver) and rollOut. I’m not sure why and i would like to know so i can steer clear from this problem. i uploaded an example i made of this problem happening. download it [[color=#22229c]Here.[/color]](http://www.joannsnyder.com/buttonuse.zip)

---

<div class="post-metadata">

**Author:** ![2nd\_day](https://avatars.discourse-cdn.com/v4/letter/2/a4c791/32.png) [@2nd\_day](https://forum.kirupa.com/u/2nd_day)\
**Post date:** [July 24, 2004, 9:13pm UTC](https://forum.kirupa.com/t/problems-with-on-and-onclipevent/117137/2 "2004-07-24T21:13:07Z")

</div>

the onEnterFrame was messing things a bit, so i rewrote it. i wrote a function you can place on the first frame of the main timeline. but first you have to delete the onClipEvent(enterFrame) for every button/movieclip and give every mc/btns an instance name. here is the new code for the btn/mc:

```auto

///the rollover and rollout don't seem to work
on (rollOver) {
	if (_currentframe<=10) {
		gotoAndPlay(2);
	}
}
on (rollOut) {
	if (_currentframe<=10) {
		gotoAndPlay(1);
	}
}

//////////////////////////////////
on (release) {
	if (_currentframe<=10) {
		this.gotoAndPlay(11);
		this.useHandCursor = false;
		_root.change("instancename", _root.clicked);
	}
}

```

now the function witch, as you can see is called by on(release)

```auto

function change(i, k) {
	tellTarget (k) {
		gotoAndPlay(1);
	}
	_root.clicked = i;
}

```
