0
我一直无法建立一种机制,允许用户从一个时间轴中选择时间跨度。基本上,我希望他们能够点击和拖动水平,并检索该事件的开始和结束位置。创建拖动条纯ActionScript中
我特别需要该事件熄灭屏幕(即使结束位置捕捉到这很好的屏幕边缘)的边缘,包括案件。
在做所有这些工作时,我希望能够绘制一个从事件开始到鼠标当前位置的框,以便明确选择哪个区域。
我一直无法建立一种机制,允许用户从一个时间轴中选择时间跨度。基本上,我希望他们能够点击和拖动水平,并检索该事件的开始和结束位置。创建拖动条纯ActionScript中
我特别需要该事件熄灭屏幕(即使结束位置捕捉到这很好的屏幕边缘)的边缘,包括案件。
在做所有这些工作时,我希望能够绘制一个从事件开始到鼠标当前位置的框,以便明确选择哪个区域。
基本上,它似乎没有我,你拖的东西。你只需要按一下,移动和释放。你必须点击的东西,我敢打赌,你可以考虑在时间轴本身的新闻发布会。所以它会是这样的:
timeline.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
timeline.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
// the next line just considers that leaving the object surface is the same as depressing the mouse button
timeline.addEventListener(MouseEvent.MOUSE_OUT, onMouseUp);
function onMouseDown(evt:MouseEvent):void {
// add the event listener for the mouse move action
timeline.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
// create the movie clip for the box
// you get the mouse coordinates from evt.localX and evt.localY (relative to the origin of the timeline movieclip) or evt.stageX and evt.stageY (as global values)
}
function onMouseMove(evt:MouseEvent):void {
// adjust the selection width and height
// you get the mouse coordinates from evt.localX and evt.localY (relative to the origin of the timeline movieclip) or evt.stageX and evt.stageY (as global values)
}
function onMouseUp(evt:MouseEvent):void {
// remove the event listener for the mouse move, that means that the function onMouseMove will no longer be called
timeline.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
// brush up and send the final coordinates of the selection to the next function
}
对于选择图形本身,你可以使用一个影片剪辑实例从资料库,或者你可以简单地创建一个空的影片剪辑,使它半透明和借鉴一个矩形,就像这样:
var selection:MovieClip = new MovieClip();
selection.alpha = 0.5;
selection.graphics.beginFill(0x000000);
selection.graphics.drawRect(x,y,width,height);
selection.graphics.endFill();
this.addChild(selection);