X Movement Help

Hey guys,

This is my first post here on the forums (as you can probably tell), but anyway, I am creating my flash game and I have my character, I was originially going to make him move by using the arrow keys which I had set up fine but then I changed my mind and am using the mouse.

I need it so when you click on the stage, it increases the characters X untill he reaches the point. This is what I had come up with:


 
var CharSpeed:Number = 5
 
stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseXPos);
 
function MouseXPos (e:MouseEvent)
{
 var MouseX = trace(stage.mouseX);
}
 
 if(MouseX < Character.x)
{
Character.x += CharSpeed
}
 

I figure this doesnt work because MouseX is inside of the MouseXPos function…

Any help would be great

-Kaine