0

创建游戏拖放类型没有“目标区域(当您将鼠标悬停在按钮上时,它会播放视频)我想要当您将项目拖动到视频时,如果您释放项​​目,它会弹回原位.

这是我现在拥有的代码...

mc_d4.addEventListener(MouseEvent.MOUSE_DOWN, dragD4);
stage.addEventListener(MouseEvent.MOUSE_UP, dragStop4);
function dragD4(e:Event):void {
mc_d4.startDrag();
}
function dragStop4(e:Event):void {
    mc_d4.stopDrag();
}
4

1 回答 1

0

您必须将当前拖动项目的位置保存在某处。简单的解决方案是将其保存在变量中

var startPosition:Point;

mc_d4.addEventListener(MouseEvent.MOUSE_DOWN, dragD4);
stage.addEventListener(MouseEvent.MOUSE_UP, dragStop4);

function dragD4(e:Event):void {
   mc_d4.startDrag();
   startPosition = new Point( mc_d4.x, mc_d4.y);
}

function dragStop4(e:Event):void {
   mc_d4.stopDrag();
   //set back or tween position

   mc_d4.x = startPosition.x;
   mc_d4.y = startPosition.y;

   startPosition = null;

}
于 2013-04-05T18:10:47.433 回答