# Navigation Problem

**URL:** <https://forum.kirupa.com/t/navigation-problem/137412>\
**Category:** Uncategorized\
**Created:** [February 14, 2005, 12:38pm UTC](https://forum.kirupa.com/t/navigation-problem/137412 "2005-02-14T12:38:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamin](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@kamin](https://forum.kirupa.com/u/kamin)\
**Post date:** [February 14, 2005, 12:38pm UTC](https://forum.kirupa.com/t/navigation-problem/137412/1 "2005-02-14T12:38:42Z")

</div>

Hi, I’m hoping that someone is able to help me with my problem. I am creating a system for children to encourage mouse based navigation. The interface is based on a street map with a number of houses on it, and its up to the kids to move a car around the street map. There are 2 navigation methods that need to be made:

1. The car needs to follow the mouse but it only move within a certain area i.e. the on the road and not over the houses or any other part of the interface that isn’t a road. The code I have is below, but I dont know how to edit it:

onClipEvent (load) {  
\_x = 0;  
\_y = 0;  
speed = 15;  
}  
onClipEvent (enterFrame) {  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
\_x += (endX-\_x)/speed;  
\_y += (endY-\_y)/speed;  
}

1. The car needs to move to the point where the mouse is clicked, but the area is restricted only to the roads. The code for this is below, but again, I dont know how to edit it so that the car will only move within the road area:

onClipEvent (load) {  
\_x = 0;  
\_y = 0;  
speed = 15;  
}  
onClipEvent (mouseDown) {  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
}  
onClipEvent (enterFrame) {  
\_x += (endX-\_x)/speed;  
\_y += (endY-\_y)/speed;  
}

I hope that makes sense! I know it can be done, but I don’t how to do it, as I have just started using Flash.Can anyone help me please??? Thanks
