# \[AS2/CS3\] Scrolling/Mouse detection script error

**URL:** <https://forum.kirupa.com/t/as2-cs3-scrolling-mouse-detection-script-error/313849>\
**Category:** flash\
**Created:** [September 11, 2010, 5:03pm UTC](https://forum.kirupa.com/t/as2-cs3-scrolling-mouse-detection-script-error/313849 "2010-09-11T17:03:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![avalonx3](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@avalonx3](https://forum.kirupa.com/u/avalonx3)\
**Post date:** [September 11, 2010, 5:03pm UTC](https://forum.kirupa.com/t/as2-cs3-scrolling-mouse-detection-script-error/313849/1 "2010-09-11T17:03:16Z")

</div>

Hi, I modified a gallery component that I purchased, and need help with mouse detection in scrolling. Basically, I moved the “menu” thumbnails from a vertical alignment/scroll to a horizontal alignment/scroll at the bottom of the stage. Everything works great, except the mouse is detected anywhere on the screen. Meaning, if i move the mouse left to right at the top of the screen, the thumbnails at the bottom still move. I need it to detect the mouse only when the mouse is positioned above the thumbails/menu. Hope this makes sense. Below is the script from the file I’ve update. Anyone can point out where I made an error, would really appreciate it!

//BUTTON FUNCTION: GET URL  
this.image\_mc.bttn.onRelease = function() {  
getURL(launchLink, “\_blank”);  
};  
//ON THUMBNAIL PRESS FUNCTION (LOAD LARGE IMAGE)  
clickAction = function (obj) {  
this.image\_mc.holder.\_alpha = 0;  
loadMovie(image[obj.ID], this.image\_mc.holder);  
launchLink = url[obj.ID];  
txt\_mc.txt.text = full\_txt[obj.ID];  
};

// INITIAL VARIABLES (ADJUST MENU SPACING AND SCROLL BUFFER HERE)  
var menuSpacing = 1;  
var menuWidth = this.menu\_mc.image\_mc.\_width+menuSpacing;   
var boundryHeight = mask\_mc.\_height;  
var boundryWidth = mask\_mc.\_width;  
var buffer = (menuWidth)\*10;

// INITIAL MOVIECLIP SETTINGS  
menu\_mc.setMask(mask\_mc);  
hover\_mc.startDrag([lockCenter]);  
hover\_mc.\_visible = false;  
txt\_mc.\_visible = false;

// LOAD FIRST IMAGE / COPY ON STARTUP  
loadMovie(image[0], this.image\_mc.holder);  
launchLink = url[0];  
txt\_mc.txt.text = full\_txt[0];

//BUILD THUMBNAIL MENU BASED ON XML DATA  
for (i=0; i\<total; ++i) {  
this.menu\_mc.image\_mc.duplicateMovieClip(“image\_mc”+i, i);  
this.menu\_mc[“image\_mc”+i].\_x = (menuWidth)\*i; //this.menu\_mc[“image\_mc”+i].\_y = (menuHeight)_i;  
loadMovie(thumb_, this.menu\_mc[“image\_mc”+i].holder);  
this.menu\_mc[“image\_mc”+i].ID = i;  
}

//SCOLLING MENU SCRIPT (DETECT MOUSE POSITION)  
this.onMouseMove = function() {  
if (this.\_xmouse\>0 && this.\_xmouse\<boundryWidth) {   
if (this.\_xmouse\>0 && this.\_xmouse\<boundryWidth) {   
ratio = this.\_xmouse/boundryWidth;   
diff = menu\_mc.\_width-boundryWidth+buffer;   
destX = Math.floor(-ratio\*diff)+buffer/2;   
}  
}  
};  
this.onEnterFrame = function() {

```
//SHOW AND HIDE COPY TEXT ON IMAGE ROLLOVER
if (image_mc.holder.hitTest(_parent._xmouse, _parent._ymouse, true)) {
	txt_mc._visible = true;
	txt_mc.txt._height = txt_mc.txt.textHeight+5;
	txt_mc.bg._height = txt_mc.txt._height+20;
	txt_mc._x = image_mc._width-txt_mc._width;             		
	txt_mc._visible = true;
} else {
	txt_mc._visible = false;
}

//SCOLLING MENU SCRIPT (SCROLL EASING)
menu_mc._x += (destX-menu_mc._x)/5;                          	
if (menu_mc._x&gt;0) { 											
	menu_mc._x = 0; } else if (menu_mc._x&lt;(boundryWidth-menu_mc._width)) { 			
	menu_mc._x = boundryWidth-menu_mc._width; 				
}

```

};  
stop();
