A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [Problem] Inventory System not wroking? AS2

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    2

    [Problem] Inventory System not wroking? AS2

    well i found an inventory tutorial on this very website and had to mod it around to fit my game, so i have this function

    Code:
    function addToslot(item1) {
    		var addItem1 = _root.backpack.attachMovie(item1, item1, 1);
    		addItem1._x = eval("_root.backpack.itemSlot"+currentslotnum)._x;
    		addItem1._y = eval("_root.backpack.itemSlot"+currentslotnum)._y;
    		currentslotnum++;
    	}
    so that works, but when you start the game, i did this code
    Code:
    _root.warriorSprite10.addToslot("starterBladeI");
    and that worked, starterBladeI went to the right slot, but then when i use this code to get another weapon
    Code:
    _root.warriorSprite10.addToslot("shortSwordI");
    the shortSwordI goes to the second slot, but the starterBladeI disappears. anyone see an obvious error?

  2. #2
    Senior Member
    Join Date
    May 2003
    Location
    Austria
    Posts
    146
    You are adding every item with the same depth!

    Change this line

    PHP Code:
    var addItem1 _root.backpack.attachMovie(item1item11); 
    to

    PHP Code:
    var addItem1 _root.backpack.attachMovie(item1item1currentslotnum); 

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    that worked perfectly thanks so much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center