Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

shuffle movie clips on stage

Explorer ,
Feb 27, 2013 Feb 27, 2013

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));

TOPICS
ActionScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 27, 2013 Feb 27, 2013

after i saw your message about your mc's being on-stage, i changed the code.

copy and paste the edited code.

Translate
LEGEND ,
Feb 27, 2013 Feb 27, 2013

How are you adding your movieclips now?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2013 Feb 27, 2013

they are on stage with their instance name m1 to m24

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2013 Feb 27, 2013

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;

        a = temp;

    }

    return a;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2013 Feb 27, 2013

it's not working

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2013 Feb 27, 2013

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 imagegame.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2013 Feb 27, 2013

after i saw your message about your mc's being on-stage, i changed the code.

copy and paste the edited code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2013 Feb 27, 2013

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2013 Feb 27, 2013

DONE !!!!

Kglad thank you very much for your help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2013 Feb 27, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines