Hello,
i have this script that arranges display objects in a grid formation.So far so good.What i would like to archieve is that the “clips” appear randomly with active and inactive “clips”.Anyone with a tip ?
//set how many boxes we want
var boxNum:int = 17;
// set how many columns our grid is going to have
var cols:int = 4;
// calculate how many rows we need, based on boxNum
var rows:int = Math.ceil(boxNum / cols);
// the number of boxes attached to the stage
var boxCount:int = 0;
for (var py:int = 0; py <rows; py++) {
for (var px:int = 0; px <cols; px++) {
var box:Box = new Box();
box.x = 50 + box.width * px;
box.y = 50 + box.height * py;
addChild(box);
// only add listeners if box should be active
if (boxCount <boxNum) {
box.buttonMode = true;
box.addEventListener(MouseEvent.ROLL_OVER, onOver,
false, 0, true);
box.addEventListener(MouseEvent.ROLL_OUT, onOut,
false, 0, true);
} else {
// box is inactive
box.alpha = 0.5;
}
boxCount++;
}
}
function onOver(evt:Event):void {
var box:MovieClip = MovieClip(evt.target);
addChild(box)
box.scaleX = box.scaleY = 1.3;
}
function onOut(evt:Event):void {
evt.target.scaleX = evt.target.scaleY = 1;
}