# Explain actionscript please

**URL:** <https://forum.kirupa.com/t/explain-actionscript-please/186802>\
**Category:** programming\
**Created:** [April 24, 2006, 6:46pm UTC](https://forum.kirupa.com/t/explain-actionscript-please/186802 "2006-04-24T18:46:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhryn](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@Dhryn](https://forum.kirupa.com/u/Dhryn)\
**Post date:** [April 24, 2006, 6:46pm UTC](https://forum.kirupa.com/t/explain-actionscript-please/186802/1 "2006-04-24T18:46:55Z")

</div>

I found the following code in a tutorial:

if (\_root.stage1.hitTest(getBounds(\_root).xMax, \_y, true)) {  
\_root.stage1.\_x += mySpeed;  
}  
if (\_root.stage1.hitTest(getBounds(\_root).xMin, \_y, true)) {  
\_root.stage1.\_x -= mySpeed;  
}  
if (\_root.stage1.hitTest(\_x, getBounds(\_root).yMax, true)) {  
\_root.stage1.\_y += mySpeed;  
}  
if (\_root.stage1.hitTest(\_x, getBounds(\_root).yMin, true)) {  
\_root.stage1.\_y -= mySpeed;  
}

and modified it to work for my file, but it didnt come with an explination for how it works, I am main confused by the getBounds part, can some please explain this code to me?

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 24, 2006, 6:57pm UTC](https://forum.kirupa.com/t/explain-actionscript-please/186802/2 "2006-04-24T18:57:49Z")

</div>

```auto

if (_root.stage1.hitTest(getBounds(_root).xMax, _y, true)) {
_root.stage1._x += mySpeed;
}
if (_root.stage1.hitTest(getBounds(_root).xMin, _y, true)) {
_root.stage1._x -= mySpeed;
}
if (_root.stage1.hitTest(_x, getBounds(_root).yMax, true)) {
_root.stage1._y += mySpeed;
}
if (_root.stage1.hitTest(_x, getBounds(_root).yMin, true)) {
_root.stage1._y -= mySpeed;
}

```

```auto

if (_root.stage1.hitTest(getBounds(_root).xMax, _y, true)) {
_root.stage1._x += mySpeed;
}

```

This is for xmax = the highest point of \_x in your movieclip like right side  
xmin is the lowest xpoint to the left.  
the same is for ymax and ymin.  
hope that clears something up :S

---

<div class="post-metadata">

**Author:** ![Dhryn](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@Dhryn](https://forum.kirupa.com/u/Dhryn)\
**Post date:** [April 24, 2006, 7:07pm UTC](https://forum.kirupa.com/t/explain-actionscript-please/186802/3 "2006-04-24T19:07:39Z")

</div>

so does:

if (\_root.stage1.hitTest(getBounds(\_root).xMax, \_y, true)) {  
\_root.stage1.\_x += mySpeed;  
}

mean the right side of the object with any value for y?  
and I am guessing the true part means that it does hit.

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 25, 2006, 3:36pm UTC](https://forum.kirupa.com/t/explain-actionscript-please/186802/4 "2006-04-25T15:36:50Z")

</div>

um yeah that means the right side of the object. Actually i dont know so much about getBounds I think they are quite weird aswell. But if you know what each line does im sure you can use it =)
