# Object move, HitTest, arrow keys

**URL:** <https://forum.kirupa.com/t/object-move-hittest-arrow-keys/243933>\
**Category:** flash\
**Created:** [November 12, 2007, 6:41pm UTC](https://forum.kirupa.com/t/object-move-hittest-arrow-keys/243933 "2007-11-12T18:41:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zosia](https://avatars.discourse-cdn.com/v4/letter/z/c0e974/32.png) [@Zosia](https://forum.kirupa.com/u/Zosia)\
**Post date:** [November 12, 2007, 6:41pm UTC](https://forum.kirupa.com/t/object-move-hittest-arrow-keys/243933/1 "2007-11-12T18:41:36Z")

</div>

hi! i have an object and a box around it  
i want my object to be only in the box area.  
so it shouldn’t be move through it.  
i know how to stop it when the object hits the wall, but then everything stops.

```
    ActionScript Code:
 [FONT=Courier New][LEFT][COLOR=#000000] **var** [/COLOR] speed:[COLOR=#0000ff]int[/COLOR]=[COLOR=#000080]5[/COLOR];     

```

[COLOR=#000000] **var** [/COLOR] [COLOR=#0000ff]stop[/COLOR]:[COLOR=#0000ff]Boolean[/COLOR]=[COLOR=#000000] **false** [/COLOR];  
[COLOR=#000000] **var** [/COLOR] \_hit:[COLOR=#0000ff]Boolean[/COLOR]=[COLOR=#000000] **false** [/COLOR]; [COLOR=#000000]\*\*

var\*\*[/COLOR] hit:[COLOR=#0000ff]Boolean[/COLOR] = [COLOR=#0000ff]HitTest[/COLOR].[COLOR=#000080]complexHitTestObject[/COLOR][COLOR=#000000]([/COLOR] [COLOR=#0000ff]object[/COLOR], wall, [COLOR=#000080]1[/COLOR] [COLOR=#000000])[/COLOR];  
[COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR] hit != \_hit [COLOR=#000000])[/COLOR]  
[COLOR=#000000]{[/COLOR] \_hit = hit;  
[COLOR=#0000ff]stop[/COLOR]=[COLOR=#000000] **true** [/COLOR];  
trace[COLOR=#000000]([/COLOR][COLOR=#ff0000]“object hits the wall”[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#000000]}[/COLOR]

```
[COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]![COLOR=#0000ff]stop[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  

```

[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR] [COLOR=#0000ff]object[/COLOR].[COLOR=#000080]x[/COLOR]-=[COLOR=#000080]2[/COLOR] \* speed; [COLOR=#000000]}[/COLOR]  
[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR] [COLOR=#0000ff]object[/COLOR].[COLOR=#000080]x[/COLOR]+=[COLOR=#000080]2[/COLOR] \* speed; [COLOR=#000000]}[/COLOR]  
[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR] [COLOR=#0000ff]object[/COLOR].[COLOR=#000080]y[/COLOR]-=[COLOR=#000080]2[/COLOR] \* speed; [COLOR=#000000]}[/COLOR] [COLOR=#0000ff]  
if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR] [COLOR=#0000ff]object[/COLOR].[COLOR=#000080]y[/COLOR]+=[COLOR=#000080]2[/COLOR] \* speed; [COLOR=#000000]}[/COLOR]

[COLOR=#000000]}

does anybody know how can i keep my object in the box (wall) area?  
attached image is how it looks like  
[/COLOR] [/LEFT]  
[/FONT]
