# Problems with On and OnClipEvent

**URL:** https://forum.kirupa.com/t/problems-with-on-and-onclipevent/58667
**Category:** flash
**Created:** [July 24, 2004, 8:01pm UTC](https://forum.kirupa.com/t/problems-with-on-and-onclipevent/58667 "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/58667/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: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 9:13pm UTC](https://forum.kirupa.com/t/problems-with-on-and-onclipevent/58667/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;
}

```
