# Mouse Movement Help

**URL:** <https://forum.kirupa.com/t/mouse-movement-help/219519>\
**Category:** flash\
**Created:** [March 17, 2007, 12:00pm UTC](https://forum.kirupa.com/t/mouse-movement-help/219519 "2007-03-17T12:00:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![meetmurali](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@meetmurali](https://forum.kirupa.com/u/meetmurali)\
**Post date:** [March 17, 2007, 12:00pm UTC](https://forum.kirupa.com/t/mouse-movement-help/219519/1 "2007-03-17T12:00:41Z")

</div>

[FONT=verdana, arial, helvetica][SIZE=2]Hi to all,

This is vertical xml gallery code, where the mouse will move up, then the scoller will move up and vice versa. now i want the reverse . if it move up , then the scoller come down and if it move down , then the scoller move up.

Can anyone please help me.

Thanks

[/SIZE][/FONT]

```auto
[COLOR=#000087]this[/COLOR].[COLOR=#000087]onEnterFrame[/COLOR] = [COLOR=#000087]function[/COLOR]()
{
        mask_y = [COLOR=#000087]_root[/COLOR].main.verti.mask.[COLOR=#000087]_y[/COLOR];
        mask_h = [COLOR=#000087]_root[/COLOR].main.verti.mask.[COLOR=#000087]_height[/COLOR];
        mask_middle = (mask_y + mask_h) / 2; [COLOR=#878787]// take middle of mask as reference
[/COLOR]        
        roller_y = [COLOR=#000087]_root[/COLOR].main.verti.roller.[COLOR=#000087]_y[/COLOR];
        roller_h = [COLOR=#000087]_root[/COLOR].main.verti.roller.[COLOR=#000087]_height[/COLOR];
        ymouse = [COLOR=#000087]_root[/COLOR].main.verti.mask.[COLOR=#000087]_ymouse[/COLOR];
        
        [COLOR=#878787]// if mous out of range
[/COLOR] [COLOR=#000087]if[/COLOR] (ymouse < mask_y || ymouse> mask_y + mask_h)
        speed = 0;
        [COLOR=#000087]else[/COLOR]
        speed = (ymouse - mask_middle)/ 10;
        [COLOR=#878787]// calculate speed -> the closer to middle-> slower, closer to edges-> faster
[/COLOR]        
        
        [COLOR=#878787]// if roller bottom reaches mask bottom and scroll up, stop
[/COLOR] [COLOR=#000087]if[/COLOR] ((roller_y+roller_h)<(mask_y+mask_h) && speed < 0)
        speed = 0;
        [COLOR=#878787]// if roller top reaches mask top and scroll down, stop
[/COLOR] [COLOR=#000087]if[/COLOR] (roller_y > mask_y && speed > 0)
        speed = 0;
        [COLOR=#000087]_root[/COLOR].main.verti.roller.[COLOR=#000087]_y[/COLOR] += speed;
}
[COLOR=#000087]stop[/COLOR]();

```
