Helpful Information
 
 
Category: Game Development
Why won't inventory work inside a mc?

Hi, I made an inventory and it works, the problem is that I need it to be inside a movieclip (menu) but it won't work. Here's how I made it:

I made movieclips that are squares with no fill and gave the instance "itemSlot" + number (I made 16). Then I added this code to the main actions frame:

currentslotnum = 1;
stop ();
function addToslot (item) {
if (!item.found) {
item._x = eval ("itemSlot" + currentslotnum)._x;
item._y = eval ("itemSlot" + currentslotnum)._y;
item.found = true;
currentslotnum++;
}
}

And items are movieclips smaller than the slots with instance "item" + number with this code:


onClipEvent (enterFrame) {
if (_root.player.hitTest (this)) {
_root.addToslot (this);
}
}

("player" is the user)

It works, I've tested it, but only when it is out of the movieclip. Can anyone tell me how to make this work inside the movieclip?

Thanks in advance

try

_root["itemSlot" + currentslotnum];

or if the itemSlot mc is in a differnt container the reference that instead of _root










privacy (GDPR)