# More butten event handlers?

**URL:** https://forum.kirupa.com/t/more-butten-event-handlers/106567
**Category:** Uncategorized
**Created:** [April 7, 2004, 1:15am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567 "2004-04-07T01:15:21Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Kristopher](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kristopher/32/501_2.png) [@Kristopher](https://forum.kirupa.com/u/Kristopher)
#### Post date: [April 7, 2004, 1:15am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/1 "2004-04-07T01:15:21Z")

</div>

when you roll over a button, is there an event handler with an equivelant to hold or something? i want to move a MC’s \_x value left or right depending on the button being hovered over (left or right). it only works when the user PRESSES or RELEASES… and the picture in the MC is 4000 pixels wide lol.

any ideas? or will i have to create some sort of while loop?

:esmirk:

---

<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: [April 7, 2004, 1:56am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/2 "2004-04-07T01:56:27Z")

</div>

The events you want are called rollOver/rollOut. I recently participated in a thread on FlashKit that sounds like a similar problem:

[Scrolling inside a large map](http://www.flashkit.com/board/showthread.php?threadid=544798)

Flash ‘buttons’ (as opposed to plain-old movieclips) tend to eat rollOver events, so I usually use movieclips instead, if I’m doing anything remotely fancy.

\_ Jim

---

<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: [April 7, 2004, 4:52am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/3 "2004-04-07T04:52:26Z")

</div>

i’m pretty good with flash overall, i just dont know what kind of actionscript i need to make it work so there is a continous shift left or right of the picture inside an MC while the user hovers over a button (this is so they don’t have to press repeatedly).

---

<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: [April 7, 2004, 4:55am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/4 "2004-04-07T04:55:54Z")

</div>

use variables:

```php

on(press) {
pressed = 1;
}
on(release) {
pressed = 0;
}

```

```php

onEnterFrame = function() {
if(pressed) {
picture._x += 5;
}
}

```

---

<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: [April 7, 2004, 4:59am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/5 "2004-04-07T04:59:31Z")

</div>

hmm… i actually thought about this, but i’m confused as to how flash registers the on(EnterFrame) command.

for example, if i have one frame with a stop(); command right away (meaning it won’t advance past that frame), then will the on(EnterFrame) keep happening.

---

<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: [April 7, 2004, 5:02am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/6 "2004-04-07T05:02:42Z")

</div>

I believe so. But I’m not sure on that one. I mean I think I know, but I am extremely tired so I just can’t remember for sure lol.

---

<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: [April 7, 2004, 8:49pm UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/7 "2004-04-07T20:49:47Z")

</div>

lol.

---

<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: [April 7, 2004, 9:17pm UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/8 "2004-04-07T21:17:09Z")

</div>

enterFrame events, either onEnterFrame functions defined in movieclips or onClipEvent(enterFrame) events put ON movieclips run continuously based on the Flash document’s frames per second setting. They are _not_ dependant on whether or not the movieclip they are associated with are actually playing or not. So, though a movieclip may not actually be “entering” a new frame, an enterFrame event will still run after seconds/frames per seconds amount of time has passed.

---

<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: [April 7, 2004, 10:18pm UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/9 "2004-04-07T22:18:34Z")

</div>

> [@jbum](#):
>
> I recently participated in a thread on FlashKit that sounds like a similar problem:
> 
> [Scrolling inside a large map](http://www.flashkit.com/board/showthread.php?threadid=544798)

Hey Jim that’s a nice piece of work you got there! :thumb:

---

<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: [April 8, 2004, 5:00am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/10 "2004-04-08T05:00:10Z")

</div>

so doea onClipEvent(load) only happen once and onClipEvent(enterFrame) continuously happen (i.e., a 30 fps movie, it will do the code 30 times a second)?

if this is the case, it really cleared a lot up for me :).

---

<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: [April 8, 2004, 5:03am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/11 "2004-04-08T05:03:29Z")

</div>

onClipEvent(load) happens only once, when the file is first opened.

Adam

---

<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: [April 8, 2004, 6:57am UTC](https://forum.kirupa.com/t/more-butten-event-handlers/106567/12 "2004-04-08T06:57:20Z")

</div>

What you could do is set the onEnterFrame handler to make the movieclip continuously move to the left when you rollOver the left button, and have it delete the onEnterFrame handler when you rollOut that button. Since they’re buttons, I’d suggest creating an auxiliary movieclip to use it’s onEnterFrame handler because I don’t know which you are already using or not. You can use another movieclips onEnterFrame handler if you want to, I’m just using an auxiliary movieclip here to be safe.

On the timeline your buttons are in:

```auto

 this.createEmptyMovieClip("aux",786)
 leftbutton.onRollOver = function(){
 aux.onEnterFrame = function(){
 this._parent.yourThingyYouWantToMove._x-=5;
 }
 }
 rightbutton.onRollOver = function(){
  aux.onEnterFrame = function(){
  this._parent.yourThingyYouWantToMove._x+=5;
  }
  }
 leftbutton.onRollOut = rightbutton.onRollOut = function(){
  delete aux.onEnterFrame;
  }
 

```
