# Action Script to change Mc position around canvas

**URL:** https://forum.kirupa.com/t/action-script-to-change-mc-position-around-canvas/81465
**Category:** Uncategorized
**Created:** [March 2, 2005, 6:09pm UTC](https://forum.kirupa.com/t/action-script-to-change-mc-position-around-canvas/81465 "2005-03-02T18:09:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![felipegm](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@felipegm](https://forum.kirupa.com/u/felipegm)
#### Post date: [March 2, 2005, 6:09pm UTC](https://forum.kirupa.com/t/action-script-to-change-mc-position-around-canvas/81465/1 "2005-03-02T18:09:14Z")

</div>

Hi,

I´m trying to make a Mc to move around the canvas according to the mouse position. The Mc follows the mouse on the \_y coordinates.  
Now I want to make it change position on the \_x coordinates according to the mouse.  
It´s working fine on the \_xmouse position, but I´m not getting it to work in the \_ymouse position. I´d like the Mc change position when the mouse is over a determined are on the stage.

Could anyone help?

This is the code I´m using

```auto
onClipEvent (load) {
	this._x = 750;
	//set original x
	this._y = 420;
	//set original y
	divider = 5;
	//speed
	numx = this._x;
	//numx is destination x
	numy = this._y;
	//numy is destination y
}
onClipEvent (enterFrame) {
	if (_ymouse>700) {
		numx = 732;
		//set destination x
	} else {
		numx = 760;
		//set destination x
	}
}
onClipEvent (enterFrame) {
	if (_xmouse>-230) {
		numx = 732;
		//set destination x
	} else {
		numx = 760;
		//set destination x
	}
	x = numx-_x;
	//setup variable named x
	this._x += x/divider;
	//see the x transition
	//y=numy-_y; //setup variable named y
	//this._y+=y/divider; //see the y transition
}
onClipEvent (load) {
	_y = 0;
	speed = 5;
}
onClipEvent (enterFrame) {
	endY = _root._ymouse;
	_y += (endY-_y)/speed;
}

```
