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?