Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 在actionscript中创建拖动栏_Apache Flex_Flash_Actionscript 3 - Fatal编程技术网

Apache flex 在actionscript中创建拖动栏

Apache flex 在actionscript中创建拖动栏,apache-flex,flash,actionscript-3,Apache Flex,Flash,Actionscript 3,我在创建允许用户从时间轴中选择时间跨度的机制时遇到了问题。基本上,我希望他们能够水平点击和拖动,并检索该事件的开始和结束位置 我特别需要包括事件离开屏幕边缘的情况(即使结束位置捕捉到屏幕边缘也可以) 在进行所有这些操作时,我希望能够绘制一个从事件开始到鼠标当前位置的框,这样,如果选中,就可以清楚地看到哪个区域 基本上,我不觉得你在拖东西。你只需要按、移动和释放的顺序。你必须点击一些东西,我敢打赌你可以考虑时间轴上的新闻事件。所以它会是这样的: timeline.addEventListener(

我在创建允许用户从时间轴中选择时间跨度的机制时遇到了问题。基本上,我希望他们能够水平点击和拖动,并检索该事件的开始和结束位置

我特别需要包括事件离开屏幕边缘的情况(即使结束位置捕捉到屏幕边缘也可以)


在进行所有这些操作时,我希望能够绘制一个从事件开始到鼠标当前位置的框,这样,如果选中,就可以清楚地看到哪个区域

基本上,我不觉得你在拖东西。你只需要按、移动和释放的顺序。你必须点击一些东西,我敢打赌你可以考虑时间轴上的新闻事件。所以它会是这样的:

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);

基本上,我不觉得你在拖东西。你只需要按、移动和释放的顺序。你必须点击一些东西,我敢打赌你可以考虑时间轴上的新闻事件。所以它会是这样的:

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);