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
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
...Copy link to clipboard
Copied
a double for loop with a new statement inside would do it.
Copy link to clipboard
Copied
i would like to see an example
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
}
}
Copy link to clipboard
Copied
var movie:MyMovie = new MyMovie();
this statement doesnt work for me.
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.
Copy link to clipboard
Copied
have u seen the image? i AM using the same values
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.
Copy link to clipboard
Copied
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.