Can I please ask for help looking at the following code’s kinks worked out? We are trying to get a set of five buttons to glide from left to right depending on the mouse’s position within the borders of a mask. Relevant instance names are panel1 (the movie clip of buttons), mask_mc (the mask that hides the overflow).
Nothing is happening when I move the mouse over any part of the mask_mc. I have combed through this code and I am not getting any errors, but I definitely don’t have a mathematical mind.
mask_mc.addEventListener(MouseEvent.MOUSE_MOVE, panelMover);
var myLoader:Loader=new Loader ();
preloader.visible=false;
stroke.alpha=0;
var speed:Number;
var padding:Number=0;
function panelMover(event:MouseEvent):void {
if (mouseY>mask_mc.y&&mouseY<mask_mc.height) {//vertically over scroller
if (mouseX<mask_mc.x&&mouseX>mask_mc.width+mask_mc.x) {//outside of mask explicitly
speed = 0;
} else if (mouseX > mask_mc.x+mask_mc.width/2 && mouseX < mask_mc.width+mask_mc.x) {//right of stage explicitly
speed = -(mouseX - (mask_mc.width/2 )) / 7;
} else if (mouseX > mask_mc.x && mouseX < mask_mc.x+mask_mc.width/2) {
speed = +(mouseX - (mask_mc.width/2)) / 7;
}
panel1.x+=speed;
}
}
Thank you so much for any help!
Caye