[英]Flash actionscript 3 mouse out
我正在使用以下代碼在舞台上拖動對象。 我正在使用一個矩形將對象的移動限制為僅x軸。 我需要鼠標在對象之外時停止拖動。 按鈕模式關閉,但當鼠標按鈕向下移動時,鼠標仍會拖動對象。 這是我正在使用的代碼:
var rectangle:Rectangle = new Rectangle(-1400, 600, 4500, 0);
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseStartDrag);
function mouseStartDrag(motion:MouseEvent):void
{
strip_mc.startDrag(false, rectangle);
}
stage.addEventListener(MouseEvent.MOUSE_UP, mouseStopDrag);
function mouseStopDrag(motion:MouseEvent):void
{
strip_mc.stopDrag();
}
strip_mc.buttonMode = true;
Thanks for any help
您可以檢測鼠標是否在矩形內,如果不是,則可以調用strip_mc.stopDrag();
首先創建一個空的動畫片段,並向其中添加矩形。
var m:MovieClip = new MovieClip();
m.addChild(rectangle);
stage.addChild(m);
然后執行以下操作:
m.addEventListener(MouseEvent.MOUSE_OUT, mouseStopDrag);
要么
m.addEventListener(MouseEvent.ROLL_OUT, mouseStopDrag);
然后,事件偵聽器將調用已創建的mouseStopDrag
,從而停止拖動。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.