# Help from AS2 to AS3

**URL:** https://forum.kirupa.com/t/help-from-as2-to-as3/313639
**Category:** Uncategorized
**Created:** [September 5, 2010, 7:07pm UTC](https://forum.kirupa.com/t/help-from-as2-to-as3/313639 "2010-09-05T19:07:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![phantom2040](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@phantom2040](https://forum.kirupa.com/u/phantom2040)
#### Post date: [September 5, 2010, 7:07pm UTC](https://forum.kirupa.com/t/help-from-as2-to-as3/313639/1 "2010-09-05T19:07:04Z")

</div>

Hi everyone

As a beginner I having a lot of difficulties upgrade my website fom AS2 to AS3.  
I use to use a amazing piece of code that I found in this website in order to scroll the background using the mouse. It was perfect but have to upgrade…

```auto
stop();
this.onMouseMove = function() {
	constrainedMove(BigMC_mc, 30, -1);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
	var mSpeed:Number;
	var mousePercentX:Number = _xmouse/Stage.width;
	
	if (dir == 1) {
		mSpeed = 1-mousePercent;
		
	} else {
		mSpeed = mousePercent;
		
	}
	target.destY = Math.round(-((target._height-Stage.height)*mSpeed));
	
	target.onEnterFrame = function() {
		if (target._y == target.destY) {
			delete target.onEnterFrame;
		} else if (target._y>target.destY) {
			target._y -= Math.ceil((target._y-target.destY)*(speed/100));
		} else if (target._y<target.destY) {
			target._y += Math.ceil((target.destY-target._y)*(speed/100));
		}
				if ((target._y+target._height)<Stage.height) {
			target._y=Stage.height-target._height
		}
		if ((target._y)>0) {
			target._y=0
		}
ç

```

I really don’t get AS3 and wonder if anyone here has already translated this code. If yes It would be very helpful for me. If not, where can I find a code which has the same function or similar but in AS3 ?

Thanx a lot !
