# Random value from a circle....!

**URL:** <https://forum.kirupa.com/t/random-value-from-a-circle/308803>\
**Category:** Uncategorized\
**Created:** [April 30, 2010, 11:15am UTC](https://forum.kirupa.com/t/random-value-from-a-circle/308803 "2010-04-30T11:15:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthic\_vkn](https://avatars.discourse-cdn.com/v4/letter/k/da6949/32.png) [@karthic\_vkn](https://forum.kirupa.com/u/karthic_vkn)\
**Post date:** [April 30, 2010, 11:15am UTC](https://forum.kirupa.com/t/random-value-from-a-circle/308803/1 "2010-04-30T11:15:58Z")

</div>

Hi All,

I need to get a random xy value from a circle, for example going to spread circles on stage randomly. Its quiet easy to spread the circle in a square.

Here that was done…

* * *

var MC:MovieClip=new MovieClip();

var squareWidth:Number=200;  
var squareHeight:Number=200;

for (var i:int=0; i\<=100; i++) {  
MC=drawCircle();  
MC.id=i;  
MC.x=Math.random()\*squareWidth;  
MC.y=Math.random()\*squareHeight;  
addChild(MC);  
}

## function drawCircle() { var circle:MovieClip=new MovieClip(); circle.graphics.beginFill(0xFF6600); circle.graphics.drawCircle(0,0,10); return (circle); }

Can anyone modify this code and spread those circle within a circle ?
