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

Proper way to Duplicate Movieclip?

Explorer ,
Mar 24, 2018 Mar 24, 2018

Copy link to clipboard

Copied

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

TOPICS
Development

Views

833

Translate

Translate

Report

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

Advocate , Mar 28, 2018 Mar 28, 2018

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

...

Votes

Translate

Translate
Engaged ,
Mar 26, 2018 Mar 26, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Mar 26, 2018 Mar 26, 2018

Copy link to clipboard

Copied

i would like to see an example

Votes

Translate

Translate

Report

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
Advocate ,
Mar 27, 2018 Mar 27, 2018

Copy link to clipboard

Copied

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

}

}

Votes

Translate

Translate

Report

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 ,
Mar 27, 2018 Mar 27, 2018

Copy link to clipboard

Copied

var movie:MyMovie = new MyMovie();

this statement doesnt work for me.

Untitled.png

Votes

Translate

Translate

Report

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
Advocate ,
Mar 27, 2018 Mar 27, 2018

Copy link to clipboard

Copied

It's an hypothetical name, you'll have to replace it with whatever you use. All the values used are hypothetical as well, you'll have to change them to your liking. I really can't help you more than that.

Votes

Translate

Translate

Report

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 ,
Mar 27, 2018 Mar 27, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Engaged ,
Mar 27, 2018 Mar 27, 2018

Copy link to clipboard

Copied

you have to have an actionscript class linked to the symbol in the library, not an instance name, in order to be able to instantiate a symbol with code.

Votes

Translate

Translate

Report

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
Advocate ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

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