# Getting rid of a Random function but still doing the job

**URL:** https://forum.kirupa.com/t/getting-rid-of-a-random-function-but-still-doing-the-job/272380
**Category:** Uncategorized
**Created:** [October 4, 2008, 8:40pm UTC](https://forum.kirupa.com/t/getting-rid-of-a-random-function-but-still-doing-the-job/272380 "2008-10-04T20:40:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![EastVillageHC](https://avatars.discourse-cdn.com/v4/letter/e/49beb7/32.png) [@EastVillageHC](https://forum.kirupa.com/u/EastVillageHC)
#### Post date: [October 4, 2008, 8:40pm UTC](https://forum.kirupa.com/t/getting-rid-of-a-random-function-but-still-doing-the-job/272380/1 "2008-10-04T20:40:00Z")

</div>

Hey dudes i wanna make this particle effect in a movie clip and the movement, distance size of particcles and everything is generated by a random function, how exactly can i change this to make the particles move in a certain area of hte movie clip stage not all over.Here’s the code

xMin = 0;  
xMax = 550;  
yMin = 0;  
yMax = 400;  
minSize = 10;  
maxSize = 50;  
easeFactor = 10;

randomX = Math.random () \* ( xMax - xMin ) + xMin;  
randomY = Math.random () \* ( yMax - yMin ) + yMin;

* * *

distance = Math.sqrt(Math.pow(this.\_x-randomX, 2)+Math.pow(this.\_y-randomY, 2));

if (distance\>1) {  
this.\_x += (randomX-this.\_x)/easeFactor;  
this.\_y += (randomY-this.\_y)/easeFactor;  
gotoAndPlay(2);  
} else {  
gotoAndPlay(1);  
}

10x in advance:flower:
