# Mouse detection image gallery

**URL:** https://forum.kirupa.com/t/mouse-detection-image-gallery/192512
**Category:** Uncategorized
**Created:** [June 29, 2006, 2:21am UTC](https://forum.kirupa.com/t/mouse-detection-image-gallery/192512 "2006-06-29T02:21:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![aware13](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@aware13](https://forum.kirupa.com/u/aware13)
#### Post date: [June 29, 2006, 2:21am UTC](https://forum.kirupa.com/t/mouse-detection-image-gallery/192512/1 "2006-06-29T02:21:28Z")

</div>

[LEFT]help!!:h:

im trying to recreate an image gallery as shown here:  
[http://flashimagegallery.com/pics/artwork/](http://flashimagegallery.com/pics/artwork/)

basicaly when your mouse moves the image adjusts based on the ratio of the viewing area.

the setup is basicaly a viewing area mc i have called (mMask) and a picture, mc that lays behind it called pichold. these two mc’s are nested within a movie clip called viewgall. im working on this on the side to then bring into another .fla when finished. these heres what i have so far for the code:

> 

init();  
function init():Void {  
//pic = attachMovie(“pichold”, “pichold”, 0);  
picrangeX = (pichold.\_width-mMask.\_width)/2;  
picrangeY = (pichold.\_height-mMask.\_height)/2;  
centerX = mMask.\_width/2;  
centerY = int(mMask.\_height/2);  
pichold.\_x = centerX;  
pichold.\_y = centerY;  
}  
function onEnterFrame():Void {  
var dx:Number = \_xmouse-centerX;  
var dy:Number = \_ymouse-centerY;  
var angle:Number = Math.atan2(-dy, -dx);  
var speed:Number = (Math.sqrt(dx_dx+dy_dy))\*.05;  
var vx:Number = Math.cos(angle)\*speed;  
var vy:Number = Math.sin(angle)\*speed;  
if (pichold.\_x\>=(centerX+picrangeX)) {  
pichold.\_x = centerX+picrangeX;  
}  
if (pichold.\_x\<=(centerX-picrangeX)) {  
pichold.\_x = centerX-picrangeX;  
}  
if (pichold.\_y\>=(centerY+picrangeY)) {  
pichold.\_y = centerY+picrangeY;  
}  
if (pichold.\_y\<=(centerY-picrangeY)) {  
pichold.\_y = centerY-picrangeY;  
}  
pichold.\_x += vx;  
pichold.\_y += vy;  
}

im wondering if i have to take into account the stages width and height at all to get this to work properly. the x and y coors for the picture are all screwed up and i dont know why?!?

im still learning the ropes here…can anyone take a look at this and help me out?

[/LEFT]
