# Mouse scroll and buttons

**URL:** <https://forum.kirupa.com/t/mouse-scroll-and-buttons/209165>\
**Category:** Uncategorized\
**Created:** [December 6, 2006, 3:19pm UTC](https://forum.kirupa.com/t/mouse-scroll-and-buttons/209165 "2006-12-06T15:19:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![benny\_hill](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@benny\_hill](https://forum.kirupa.com/u/benny_hill)\
**Post date:** [December 6, 2006, 3:19pm UTC](https://forum.kirupa.com/t/mouse-scroll-and-buttons/209165/1 "2006-12-06T15:19:20Z")

</div>

**I have created a long horizontal movie clip. Inside it are 22 buttons for a company history timeline. On the mouse over I want it to scroll in accordance to the mouse location so I used this code:**

yearHolder.onRollOver = function(){  
var leftLimit:Number = -(yearHolder.year\_mc.\_width - btnMask.\_width);  
var rightLimit:Number = -5;  
this.onEnterFrame = function(){  
if(\_xmouse \> frame\_mc.\_width/2 && yearHolder.year\_mc.\_x \>= leftLimit ){  
yearHolder.year\_mc.\_x -= 10;  
}  
else if(\_xmouse \< frame\_mc.\_width/2 && yearHolder.year\_mc.\_x \<= rightLimit){  
yearHolder.year\_mc.\_x += 10;  
}  
else{  
delete onEnterFrame;  
}

}  
}  
yearHolder.onRollOut = function(){  
delete this.onEnterFrame;  
}

**In order to get the buttons to work I created a function then called the function for each button with the instanceName for the argument:**

function buttonAction(instanceName:Button,buttonYear:Number){  
instanceName.onRelease = function(){  
itemNumber = buttonYear;  
slide(); //this moves the company history timeline  
}  
}  
buttonAction(yearHolder.year\_mc.btn1,1);  
buttonAction(yearHolder.year\_mc.btn2,2);  
buttonAction(yearHolder.year\_mc.btn3,3);  
//(there is more buttons than this is the actual code)

**Now the buttons work when then the yearHolder.onRollOver functions are commented out but when the scrolling is working (not commented out), the buttons do not work.**

Any suggestions?
