我的目标是突出显示两个可拖动对象inpoint_mc
和scrub_outpoint_mc
之间的区域,所以我在这些点之间创建了一个矩形,我需要根据拖动点调整此矩形的大小,这表示在Inpoint和Outpoint之间的距离,我尝试了我的水平,不幸的是我可以实现它
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点之间收缩
答案 0 :(得分: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);
}
应该这样做。