A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: AS 3 game with inventory : added items remain after removing them

  1. #1
    Senior Member
    Join Date
    Apr 2003
    Location
    Seattle
    Posts
    177

    AS 3 game with inventory : added items remain after removing them

    Hello,
    I am coding a game with an inventory and I am using addChild to move the item clicked into the inventory. This works fine, however when I move forward on the time line and then return back to the previous frame, the item remains where it was in addition to being in the inventory. My understanding is that the addChild method automatically removes the child from the stage when it puts it into another MC, however this is not what's happening. I've tried removeChild but since the child has initially been removed, it throws up an error message. Here's code for the function triggered by the eventListener:
    Code:
    function toInventory(event:MouseEvent):void {
    
    inventory_mc.addChild(desertflower_mc);
    trace("Flower goes to Inventory");
    desertflower_mc.x = 400;
    desertflower_mc.y = 290;
    desertflower_mc.removeEventListener(MouseEvent.MOUSE_DOWN, toInventory);

    How can I ensure that once the item is in the inventory, when I return to the frame where it was before it will no longer be there?

    Thanks in advance!

  2. #2
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,217
    can you show the file
    non-contrib

Tags for this Thread

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