Place a Movieclip at random x and y in a Range
i want to place a library item multiple times inside a movie clip over the top of another movieclip. The graphic in the other Movieclip is around object and I need the library item to appear insdie the rounded object and not ontop of each other. The round object is 240 wide and 228 high. I have most of this working except to make sure it doesnt go over the edges and tthe overlapping. Does anyone know how to place an item with in a range? I also need to be able to address the placed items in another function to cause them to play.
CODE:
var cutAway:MovieClip = new MovieClip();
var halfTomato:MovieClip = new MovieClip();
var bubblesClip:MovieClip = new MovieClip();
var bubbleArray:Array = new Array();
function createCutAway():void {
var tomatoCut = new tomatoCutaway();
var bubbleNo:Number = 9;
var nScale:Number;
trace(bubbleNo);
for (var a:int = 0; a<bubbleNo; a++) {
var bubbles = new bubble();
bubbles.x = (Math.random()*(tomatoCut.width-10));
bubbles.y = (Math.random()*(tomatoCut.height-10));
trace(bubbles.x,
bubbles.y,
tomatoCut.width,
tomatoCut.height
);
nScale = (Math.random()*3)+1;
bubbles.scaleX = nScale;
bubbles.scaleY = nScale;
bubbleArray.push(bubbles);
bubblesClip.addChild(bubbles);
}
halfTomato.addChild(tomatoCut);
halfTomato.width = 240.1;
halfTomato.height = 228.2;
cutAway.addChild(halfTomato);
cutAway.addChild(bubblesClip);
addChild(cutAway);
cutAway.x = 134;
cutAway.y = 158;
}