# Effect in certain area?

**URL:** <https://forum.kirupa.com/t/effect-in-certain-area/61274>\
**Category:** Uncategorized\
**Created:** [August 17, 2004, 1:27pm UTC](https://forum.kirupa.com/t/effect-in-certain-area/61274 "2004-08-17T13:27:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![B3NKobe](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@B3NKobe](https://forum.kirupa.com/u/B3NKobe)\
**Post date:** [August 17, 2004, 1:27pm UTC](https://forum.kirupa.com/t/effect-in-certain-area/61274/1 "2004-08-17T13:27:18Z")

</div>

Hi - in my flash site im creating i have a certain area which i call an effect box/area and in it is just going to be funny stupid little effects.

Anyway i have script to make an object move randomly around; except i do not know how to make it so that the effect is in my effect box/area instead of all over my site?? i have played around with the width and height varibles but just cant get it to work???

Here is my script:

onClipEvent (load) {  
//data you may want to change  
width = 600;  
height = 600;  
speed = Math.round(Math.random()\*2)+1;  
//initial positions  
x = Math.random()\*width;  
y = Math.random()\*height;  
this.\_x = x;  
this.\_y = y;  
x\_new = Math.random()\*width;  
y\_new = Math.random()_height;  
}  
onClipEvent (enterFrame) {  
//x movement  
if (x\_new\>this.\_x) {  
sign\_x = 1;  
} else {  
sign\_x = -1;  
}  
dx = Math.abs(x\_new-this.\_x);  
if ((dx\>speed) || (dx\<-speed)) {  
this.\_x += sign\_x_speed;  
} else {  
x\_new = Math.random()_width;  
}  
//y movement  
if (y\_new\>this.\_y) {  
sign\_y = 1;  
} else {  
sign\_y = -1;  
}  
dy = Math.abs(y\_new-this.\_y);  
if ((dy\>speed) || (dy\<-speed)) {  
this.\_y += sign\_y_speed;  
} else {  
y\_new = Math.random()\*height;  
}  
}

---

<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 17, 2004, 6:30pm UTC](https://forum.kirupa.com/t/effect-in-certain-area/61274/2 "2004-08-17T18:30:00Z")

</div>

Can you post the SWF on the net somewhere and give us the link and post the .FLA file?

---

<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 17, 2004, 10:27pm UTC](https://forum.kirupa.com/t/effect-in-certain-area/61274/3 "2004-08-17T22:27:23Z")

</div>

can you put it into a mask area. I think that should work
