Skip to main content
August 22, 2006
Question

onRollOver = onRollOut equivalent

  • August 22, 2006
  • 2 replies
  • 367 views
I'm looking to condense some code on a photo gallery I'm working on where I disable the next or previous buttons if there isn't a next or previous image to present. I wanted to break away from the standard multiple line approach...

nextBTN_mc.onRollOver = function() {
this.gotoAndStop(1);
}
nextBTN_mc.onRollOut = function() {
this.gotoAndStop(1);
}
nextBTN_mc.onRelease = function() {
this.gotoAndStop(1);
}

or

nextBTN_mc.onRollOver = function() {
this.gotoAndStop(1);
}
nextBTN_mc.onRollOut = nextBTN_mc.onRollOver;
nextBTN_mc.onRelease = nextBTN_mc.onRollOver;

Once upon a time (and I'm not sure where), I saw someone post a one line solution to this. Something like (but not):

nextBTN_mc.onRollOver([{'onRollOut', 'onRelease'}]) = function() {
this.gotoAndStop(1);
}

The syntax on the above is of course wrong but the solution I saw once was similar to this. The "([{'onRollOut', 'onRelease'}])" (or similar) may have been after the function parameters and there is probably an operator that I'm forgetting/missing. I've played around with it and searched the net but can't seem to get it to work or find it.

Anyways, if anyone out there knows the solution, I'd really appreciate a response. It was a very clever, clean and condensed solution and I'd love to find it again.

Take care,
sej
This topic has been closed for replies.

2 replies

Participating Frequently
August 22, 2006
I would probably put it all in a function so you can break it out or make the solution more complex later. Something like:

function defaultOnClick(){
//instructions here
}

buttonA_btn.onClick = defaultOnClick();
buttonB_btn.onClick = defaultOnClick();
buttonC_btn.onClick = defaultOnClick();

i realize it doesn't solve your problem, but I think you are potentially creating more problems later with practices like that.
Inspiring
August 22, 2006
Hi,

you can use this:

nextBTN_mc.onRollOver = nextBTN_mc.onRollOut = nextBTN_mc.onRelease = function() {
this.gotoAndStop(1);
}

greets,
blemmo
August 22, 2006
Hey blemmo,

Thanks for the response. That's pretty cool solution. I never thought of that one.

Thanks,
sej