# Collision detection (hitTest)

**URL:** <https://forum.kirupa.com/t/collision-detection-hittest/197409>\
**Category:** flash\
**Created:** [August 16, 2006, 3:11am UTC](https://forum.kirupa.com/t/collision-detection-hittest/197409 "2006-08-16T03:11:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![createi](https://avatars.discourse-cdn.com/v4/letter/c/90ced4/32.png) [@createi](https://forum.kirupa.com/u/createi)\
**Post date:** [August 16, 2006, 3:11am UTC](https://forum.kirupa.com/t/collision-detection-hittest/197409/1 "2006-08-16T03:11:23Z")

</div>

I have so many walls in my movie and i want to hitTest them with my instance, how can i add them all in the one line for. e.g. if(avatar.hitTest(wall1,wall2,wall3,wall4…  
help cos i’m having to write so many lines of script to make it work.

help!

here is my script …

on (press) { // when the button is pressed

myinstance.\_x +=5; // move the instance “instance” right on the x axis by 5 pixels

if (myinstance.hitTest(wall1)) { // if the instance “myinstancer” hits the instance “wall” then

myinstance.\_x -=5; // move the instance “avatar” left on the x axis by 5 pixels

Thank you…
