Drag and Drop disappear issue
Hello, I'm making a game in which I have some drag and drop items that they can be multiplied as many as you want. This items have to stay in the scene and I also have a bin in the menu where If you drag them they have to disappear.The problem is that I tried with multiple coordinates and they disappear also in the scene in the moment that I'm dragging them out of the menu. So, my question is:What could be wrong? Is the issue in the code?
Thank you for taking the time to help me. It's my first game in AS3 so I'm not so familiar with the codes.
import flash.display.Sprite;
import flash.events.MouseEvent;
DDB1.addEventListener(MouseEvent.MOUSE_DOWN, createDDB1);
var _DDB1:Sprite;
function createDDB1(evt:MouseEvent){
_DDB1 = new DDB1MC();
_DDB1.x = evt.stageX;
_DDB1.y = evt.stageY;
_DDB1.rotation = evt.currentTarget.rotation;
_DDB1.transform.colorTransform = evt.currentTarget.transform.colorTransform
addChild(_DDB1);
_DDB1.startDrag(false);
_DDB1.addEventListener(MouseEvent.MOUSE_DOWN, dragDDB1);
stage.addEventListener(MouseEvent.MOUSE_UP, dropDDB1);
}
function dragDDB1(evt:MouseEvent){
evt.stopPropagation();
_DDB1 = evt.currentTarget as Sprite;
_DDB1.startDrag(false);
stage.addEventListener(MouseEvent.MOUSE_UP, dropDDB1);
}
function dropDDB1(e:MouseEvent):void {
_DDB1.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_UP,dropDDB1);
if (_DDB1.x>700 || _DDB1.x < 755 || _DDB1.y < 240 || _DDB1.y > 155) {
_DDB1.removeEventListener(MouseEvent.MOUSE_DOWN, dragDDB1);
_DDB1.parent.removeChild(_DDB1);
}
_DDB1 = null;
}
