Hi,
i’ve read this thread and it’s about what i’m looking for. I’ve tried to follow alperarslan precious hints, but i think i do something wrong.
What i want to achieve is a random but ordered grid. like in the picture attached:
i’ve tried with a code like this:
//keep these images in the same folder with the Fla file
var numOfThumbs:Array = new Array(“t1.jpg”, “t2.jpg”, “t3.jpg”, “t4.jpg”, “t5.jpg”, “t6.jpg”,“t7.jpg”, “t8.jpg”, “t9.jpg”, “t10.jpg”);
//var numOfImages:Array = new Array(“1.jpg”, “2.jpg”, “3.jpg”, “4.jpg”, “5.jpg”, “6.j pg”);
var photos:Array = new Array();
photos = numOfThumbs;
trace(photos);
photos = shuffle(photos);
trace(photos);
//Outside of onLoad Function
function shuffle(arr) {
var tmpArr = [];
while (arr.length) {
var rand = Math.floor(Math.random()*arr.length);
tmpArr.push(arr.splice(rand, 1)[0]);
}
return tmpArr;
}
var gridSpace = 1;
var box = 90;
var a = 0;
var b = 0;
/////////////////////////////////////////////////////////////////////////////////////////////////////
//function to generate a random number
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
var buildGrid_SI:Number;
var i:Number = 0;
_local1=_root;
function buildGrid():Void {
if (i<photos.length) {
trace(i);
_local1.loader.attachMovie("thumbnail", "thumbnail"+i, i);
mc=_local1.loader["thumbnail"+i];
size=randRange(1, 2);
mc._width=box*size;
mc._height=box*size;
mc._x = (mc._width+gridSpace)*a;;
mc._y = (mc._height+gridSpace)*b;
mc.tLoader.loadMovie(photos*);
myTween = new Tween(_local1.loader["thumbnail"+i], "_alpha", mx.transitions.easing.Strong.easeOut, 0, 100, 25, false);
if (a>=2) {
a = 0;
b++;
} else {
a++;
}
i++;
} else {
clearInterval(buildGrid_SI);
}
}
buildGrid_SI = setInterval(buildGrid, 150);
//////////////////////////////////////////////////////////////////////////////
The code is a mix between alperarslan code and mine. I’ve added a setinterval control to obtain a nice composing effect. But the grid doesn’t compose as i want.
it doesn’t work as it should. Can you help me?
thank you.
Joanacarda.