在 AS3 中的 Dragable 对象之间动态绘制矩形
Dynamically draw rectangle between the Dragable objects in AS3
我的目的是突出显示两个可拖动对象 inpoint_mc
和 scrub_outpoint_mc
之间的区域,所以我在这些点之间创建了一个矩形,我需要根据拖动点调整此矩形的大小,它表示入点和出点之间的距离,我尽力了不幸的是我可以达到它
private function startScrubbingIN(_arg1:MouseEvent){
trace("scrubBarIsMovingIN");
this.cueCard.stage.addEventListener(MouseEvent.MOUSE_UP, this.stopScrubbingIN);
this.cueCard.stage.addEventListener(MouseEvent.MOUSE_MOVE, this.scrubBarIsMovingIN);
this.scrubbing = true;
var _local2:Rectangle = new Rectangle(this.controls_mc.progressBar_mc.x, this.controls_mc.inpoint_mc.y,
this.controls_mc.scrub_outpoint_mc.x-this.controls_mc.progressBar_mc.x, 0);
// now we're limiting in point to current position of out point
this.controls_mc.inpoint_mc.startDrag(false, _local2);
this.controls_mc.addChild(_seekIndicator);
_seekIndicator.graphics.beginFill(0x990000);
_seekIndicator.graphics.drawRect(this.controls_mc.inpoint_mc.x, this.controls_mc.progressBar_mc.y,
this.controls_mc.scrub_outpoint_mc.x-this.controls_mc.progressBar_mc.x, 12);
trace("_seekIndicator"+ _seekIndicator);
// _seekIndicator.width = this.controls_mc.scrub_outpoint_mc.x+ this.controls_mc.inpoint_mc.y;
}
它给我的结果就像附图一样
但红色矩形需要在 2 个点之间自行收缩
只有在停止拖动或在拖动时移动鼠标时才会重新绘制矩形。不要忘记调用 _seekIndicator.graphics.clear()
来删除旧矩形。最后,使用 this.controls_mc.scrub_outpoint_mc.x
和 this.controls_mc.inpoint_mc.x
作为边框,因为你说矩形应该在入点和出点 MC 之间,而你在宽度上使用 this.controls_mc.progressBar_mc.x
。
private function scrubBarIsMovingIN(e:MouseEvent):void {
// the startDrag dragged one of the sliders already
// existing code skipped, if any
_seekIndicator.graphics.clear();
_seekIndicator.graphics.beginFill(0x990000);
_seekIndicator.graphics.drawRect(this.controls_mc.inpoint_mc.x, this.controls_mc.progressBar_mc.y,
this.controls_mc.scrub_outpoint_mc.x-this.controls_mc.inpoint_mc.x, 12);
}
应该做的。
我的目的是突出显示两个可拖动对象 inpoint_mc
和 scrub_outpoint_mc
之间的区域,所以我在这些点之间创建了一个矩形,我需要根据拖动点调整此矩形的大小,它表示入点和出点之间的距离,我尽力了不幸的是我可以达到它
private function startScrubbingIN(_arg1:MouseEvent){
trace("scrubBarIsMovingIN");
this.cueCard.stage.addEventListener(MouseEvent.MOUSE_UP, this.stopScrubbingIN);
this.cueCard.stage.addEventListener(MouseEvent.MOUSE_MOVE, this.scrubBarIsMovingIN);
this.scrubbing = true;
var _local2:Rectangle = new Rectangle(this.controls_mc.progressBar_mc.x, this.controls_mc.inpoint_mc.y,
this.controls_mc.scrub_outpoint_mc.x-this.controls_mc.progressBar_mc.x, 0);
// now we're limiting in point to current position of out point
this.controls_mc.inpoint_mc.startDrag(false, _local2);
this.controls_mc.addChild(_seekIndicator);
_seekIndicator.graphics.beginFill(0x990000);
_seekIndicator.graphics.drawRect(this.controls_mc.inpoint_mc.x, this.controls_mc.progressBar_mc.y,
this.controls_mc.scrub_outpoint_mc.x-this.controls_mc.progressBar_mc.x, 12);
trace("_seekIndicator"+ _seekIndicator);
// _seekIndicator.width = this.controls_mc.scrub_outpoint_mc.x+ this.controls_mc.inpoint_mc.y;
}
它给我的结果就像附图一样
但红色矩形需要在 2 个点之间自行收缩
只有在停止拖动或在拖动时移动鼠标时才会重新绘制矩形。不要忘记调用 _seekIndicator.graphics.clear()
来删除旧矩形。最后,使用 this.controls_mc.scrub_outpoint_mc.x
和 this.controls_mc.inpoint_mc.x
作为边框,因为你说矩形应该在入点和出点 MC 之间,而你在宽度上使用 this.controls_mc.progressBar_mc.x
。
private function scrubBarIsMovingIN(e:MouseEvent):void {
// the startDrag dragged one of the sliders already
// existing code skipped, if any
_seekIndicator.graphics.clear();
_seekIndicator.graphics.beginFill(0x990000);
_seekIndicator.graphics.drawRect(this.controls_mc.inpoint_mc.x, this.controls_mc.progressBar_mc.y,
this.controls_mc.scrub_outpoint_mc.x-this.controls_mc.inpoint_mc.x, 12);
}
应该做的。