# Need help with hittest and scaling

**URL:** https://forum.kirupa.com/t/need-help-with-hittest-and-scaling/293938
**Category:** flash
**Created:** [August 6, 2009, 5:19am UTC](https://forum.kirupa.com/t/need-help-with-hittest-and-scaling/293938 "2009-08-06T05:19:12Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Neofatalist](https://avatars.discourse-cdn.com/v4/letter/n/22d042/32.png) [@Neofatalist](https://forum.kirupa.com/u/Neofatalist)
#### Post date: [August 6, 2009, 5:19am UTC](https://forum.kirupa.com/t/need-help-with-hittest-and-scaling/293938/1 "2009-08-06T05:19:12Z")

</div>

Hello,

I made a movie clip called mainMap and inside main map I have my main character which stays in place… a boundry area that moves… if the scale is 100, everything is fine.

but if I modify the xscale / yscale everything is thrown off… for example… the actual hittest is true several hundred pixels below where the boundry object is.

If I move all the components to the main timeline and modify the scale of root… everything is fine.

Is there any way to modify the scale without causing mis-alignment?

Code Below

//I load the position of the objects first  
function initPos(obj, solid, action, actionType, actionCall, initX, initY, wayPoint){  
//trace(“dasdasd”)  
this.objArray[i2] = {obj:obj, objX:obj.\_x, objY:obj.\_y, solid:solid, action:action, actionType:actionType, actionCall:actionCall, initX:initX, initY:initY, wayPoint:wayPoint};  
i2++;  
}

onEnterFrame = function(){  
//trace(boundry.hitTest(\_xmouse, \_ymouse, true) + “\<\<\<\<”)  
trace(this.\_xscale)  
mainDistance = checkDistance(nudgeXTemp, nudgeX, nudgeYTemp, nudgeY);  
//char1.\_x = 0//((\_parent.\_width/10));  
//char1.\_y = 0//((\_parent.\_height/10));

```
changeFace(nudgeX, nudgeXTemp, nudgeY, nudgeYTemp);	

if(mainDistance&gt;1 || moving == true){
	nudgeX += (nudgeXTemp - nudgeX)*tweener;
	nudgeY += (nudgeYTemp - nudgeY)*tweener;
	ixx++;
	collide=false;
	
	for(i=0;i&lt;objArray.length;i++){
		collide = checkCollision(this.objArray*.obj, this.objArray*.solid, this.objArray*.action, this.objArray*.actionType, this.objArray*.actionCall);
		
		//trace(collide+"-"+ixx)
		if(!collide) {

			this.objArray*.obj._x = this.objArray*.objX + nudgeX;
			this.objArray*.obj._y = this.objArray*.objY + nudgeY;
			//trace("processing" + ixx)
		}else{
			this.objArray*.obj._x = this.objArray*.objX + nudgeXTemp;
			this.objArray*.obj._y = this.objArray*.objY + nudgeYTemp;
			trace("COLLISION!!!")
		}
			this.objArray*.obj._x = this.objArray*.objX + nudgeX;
			this.objArray*.obj._y = this.objArray*.objY + nudgeY;
		
	}

}else{
	moving=false;
	nudgeX = nudgeXTemp;
	nudgeY = nudgeYTemp;
	this.objArray*.obj._x = nudgeX;
	this.objArray*.obj._y = nudgeY;
	//trace("colide")
}
boundryX= nudgeX - nudgeXTemp + xx + nudgeCharX;
boundryY= nudgeY - nudgeYTemp + yy + nudgeCharY + 0;
	
if(mainDistance&lt;1) moving = false;

```

}

function checkDistance(x1, x2, y1, y2){  
xdist = Math.round(x2 - x1);  
ydist = Math.round(y2 - y1);  
dist = Math.round(Math.sqrt((xdist_xdist) +(ydist_ydist)));   
return dist;  
}

function checkCollision(obj, solid, action, actionTag, actionCall){  
hit = “”;  
if(actionTag==“XX”){   
//trace(boundry.\_y + “xxxx” + obj.\_y + “—\>” char1.\_y)  
}

```
if(obj.hitTest(char1._x+nudgeCharX*1.5, char1._y+nudgeCharY*1.5, true)){
	if(solid && action=="none"){
		return true;

	}else if(solid && action==""){
		return false;			
	}else if (!solid && actionCall=="rollOver"){
		node = actionTag;
		
		trace(node)
		if(action=="slides"){
			playSlides(actionTag);
			
			
			return false;	
		}
		if(action=="movies"){
			playMovie(actionTag);
			return false;
		}			
		
	}else{return false;}
}else{
	return false;
}

```

}

please help. thanks!
