【发布时间】:2014-01-22 01:23:27
【问题描述】:
我想在某些 UIComponent 上调用 startDrag,然后在每次拖动组件的位置发生变化时接收事件。这可能吗?我还没有发现任何可能性。
【问题讨论】:
-
也许检查鼠标移动处理程序中是否有东西被拖动。
标签: actionscript-3 flash apache-flex actionscript flex4
我想在某些 UIComponent 上调用 startDrag,然后在每次拖动组件的位置发生变化时接收事件。这可能吗?我还没有发现任何可能性。
【问题讨论】:
标签: actionscript-3 flash apache-flex actionscript flex4
我认为您可能想要使用 MouseDown、MouseMove 和 MouseUp。
var myUIComponent
var isDown:Boolean = false;
var startX:Number = 0;
var startY:Number = 0;
myUIComponent.addEventListener(MouseEvent.MOUSE_DOWN, down);
function down(e:MouseEvent){
startX = e.stageX;
startY = e.stageY;
isDown = true;
stage.addEventListener(MouseEvent.MOUSE_MOVE,moving);
stage.addEventListener(MouseEvent.MOUSE_UP, up);
}
function moving(e:MouseEvent)
{
if (isDown){
var distanceX = startX - e.stageX;
var distanceY = startY - e.stageY;
// Do something
}
}
function up(e:MouseEvent)
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE,moving);
stage.removeEventListener(MouseEvent.MOUSE_UP, up);
isDown = false;
}
【讨论】: