More butten event handlers?

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:

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

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

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).

use variables:


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


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

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.

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.

lol.

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.

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

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 :).

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

Adam

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:


 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;
  }