Skip to main content
GogetaX
Inspiring
March 24, 2018
Answered

Proper way to Duplicate Movieclip?

  • March 24, 2018
  • 1 reply
  • 1223 views

im trying to make some sort of "Inventory" grid where i created a small 64x64 box as a MovieClip witch gonna be an empty inventory item.

i want to duplicate it 10 to width and 6 to height.

whats the best way to duplicate this box to make this inventory grid includign arrays as handle?

im pretty sure this question already asked so many times, but i cannot find a proper answer for it. been trying lots of different stuff, non of them worked

im using ActionScript 3.0 and Flash Anim CC

This topic has been closed for replies.
Correct answer ASWC

have u seen the image? i AM using the same values


It seems very important for you to avoid using classes of any kind which for beginners can be understood to some extent. But here you are hitting a wall, to put it simply, if you don't use classes then you cannot do what you ask.

Classes give objects a definition, definitions can be used to duplicate/clone objects, your movie has NO definitions, your movie CANNOT be duplicated/cloned by code.

So if you stick to your question and requirements then the correct answer to your question is: impossible to do because you don't use classes.

1 reply

kheftel
Inspiring
March 26, 2018

a double for loop with a new statement inside would do it.

GogetaX
GogetaXAuthor
Inspiring
March 26, 2018

i would like to see an example

Inspiring
March 27, 2018

var htotalitems:int = 6;

var vtotalitems:int = 4;

var itemwidth:int = 64; // new MyMovie().width;

var itemheight:int = 64; // new MyMovie().height;

var xgap:int = 3;

var ygap:int = 3;

var xstart:int = 100;

var ystart:int = 200;

var xpos:int = xstart;

var ypos:int = ystart;

for(var i:int = 0; i < (htotalitems * vtotalitems); i++)

{

var movie:MyMovie = new MyMovie();

addChild(movie);

movie.x = xpos;

movie.y = ypos;

xpos += itemwidth + xgap;

if((i + 1) % htotalitems == 0)

{

xpos = xstart;

ypos += itemheight + ygap

}

}