# Boundaries

**URL:** <https://forum.kirupa.com/t/boundaries/62382>\
**Category:** Uncategorized\
**Created:** [August 27, 2004, 10:20am UTC](https://forum.kirupa.com/t/boundaries/62382 "2004-08-27T10:20:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skribble](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Skribble](https://forum.kirupa.com/u/Skribble)\
**Post date:** [August 27, 2004, 10:20am UTC](https://forum.kirupa.com/t/boundaries/62382/1 "2004-08-27T10:20:27Z")

</div>

is there any easy way to make boundaries for the eadg of the stage? instead of making 4 separate MC’s. I can use the width and hieght variables of the stage to do it but it would still require 4 bits of code. So just wondering if anyone knows a way?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 1:27pm UTC](https://forum.kirupa.com/t/boundaries/62382/2 "2004-08-27T13:27:43Z")

</div>

this is the only way i know

onClipEvent(enterFrame){  
if (this.\_x\<0){  
this.\_x=0;  
}  
if (this.\_y\<0){  
this.\_y=0;  
}  
if (this.\_y\>300){  
this.\_y=300;  
}  
if (this.\_x\>300){  
this.\_x=300;  
}  
}

i don’t think there’s any other way but is this not efficient enough?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 4:28pm UTC](https://forum.kirupa.com/t/boundaries/62382/3 "2004-08-27T16:28:16Z")

</div>

ya that looks right

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 7:23pm UTC](https://forum.kirupa.com/t/boundaries/62382/4 "2004-08-27T19:23:21Z")

</div>

yeh thats wot i would usualy use. I wos thinking sumthing like have \_x positions on both sides in one statment.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 9:24pm UTC](https://forum.kirupa.com/t/boundaries/62382/5 "2004-08-27T21:24:14Z")

</div>

hmm i don’t think that’s possible…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2004, 1:58am UTC](https://forum.kirupa.com/t/boundaries/62382/6 "2004-08-30T01:58:00Z")

</div>

god moopers ur a flash genuis help me out man! check my many threads

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2004, 9:31am UTC](https://forum.kirupa.com/t/boundaries/62382/7 "2004-08-30T09:31:44Z")

</div>

i did it ^.^. i just used

if (\_x+Speed\>Stage.width || \_x+Speed\<0)

and same with the height. Just thought i would let u know it is possible.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 2:40pm UTC](https://forum.kirupa.com/t/boundaries/62382/8 "2004-09-02T14:40:11Z")

</div>

> [@Skribble](#):
>
> i did it ^.^. i just used
> 
> if (\_x+Speed\>Stage.width || \_x+Speed\<0)
> 
> and same with the height. Just thought i would let u know it is possible.

Or do this so if the area changes, the bounding area changes. This is recommended if you like to initialize your values elsewhere (like at the start 🙂

onClipEvent(enterFrame){  
if (this.\_x\<CurrentxLeft){  
this.\_x=minBoundx;  
}  
if (this.\_y\<CurrentyTop){  
this.\_y=minBoundy;  
}  
if (this.\_y\>CurrentyBottom){  
this.\_y=maxBoundy;  
}  
if (this.\_x\>CurrentxRight){  
this.\_x=maxBoundx;  
}  
}
