Copy link to clipboard
Copied
How i add my movieclips on stage in array
when load swf onstage movieclip change their position according to array
my movieclips names are m1,m2 to m24 in 6column x4rows
PLEASE HELP ME
var numberArray_arr:Array = new Array('0','1','2','3','4','5','6','7','8','9');
function arrayShuffle(array_arr:Array):Array{
for(var i:Number = 0; i < array_arr.length; i++){
var randomNum_num = Math.floor(Math.random() * array_arr.length)
var arrayIndex = array_arr;
array_arr = array_arr[randomNum_num];
array_arr[randomNum_num] = arrayIndex;
}
return array_arr;
}
trace(arrayShuffle(numberArray_arr));
after i saw your message about your mc's being on-stage, i changed the code.
copy and paste the edited code.
Copy link to clipboard
Copied
How are you adding your movieclips now?
Copy link to clipboard
Copied
they are on stage with their instance name m1 to m24
Copy link to clipboard
Copied
var mcA:Array = [m1,m2,...,m24];
var positionA:Array = [];
for(var i:Number=0;i<mcA.length;i++){
postionA.push([mcA._x,mcA._y]);
}
shuffleF(mcA);
positionF();
function positionF():Void{
for(var i:Number=0;i<mcA.length;i++){
mcA._x = positionA[0];
mcA._y = positionA[1];
}
}
function shuffleF(a:Array):Array {
n = a.length;
while (n>1) {
k = Math.floor(Math.random()*n);
n--;
temp = a
a
a
}
return a;
}
Copy link to clipboard
Copied
it's not working
Copy link to clipboard
Copied
now it's working but position of movieclip out of stage
function positionF():Void{
for(var i:Number=0;i<mcA.length;i++){
mcA._x = (i%6)*Stage.width/6;
mcA._y = Math.floor(i/6)*Stage.height/4;
}
}
see this image
Copy link to clipboard
Copied
after i saw your message about your mc's being on-stage, i changed the code.
copy and paste the edited code.
Copy link to clipboard
Copied
that code is not working
that's why i add this code
mcA._x = (i%6)*Stage.width/6;
mcA._y = Math.floor(i/6)*Stage.height/4;
Copy link to clipboard
Copied
DONE !!!!
Kglad thank you very much for your help
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now