在 HDividedBox 中一次移动多个分隔线
我正在尝试在图表下方显示一个带有可拖动视口的小地图。我基本上用它来控制图表的视口:
<mx:annotationElements>
<mx:HDividedBox id="dividedBox" horizontalScrollPolicy="off" width="100%" height="100%" liveDragging="true" borderSides="bottom top">
<mx:Canvas id="leftBox" backgroundColor="#FFFFFF" backgroundAlpha="0.5" width="50%" height="100%" borderColor="#333333" borderThickness="1" borderStyle="solid" borderSides="top right bottom" />
<mx:Canvas id="centerBox" backgroundColor="#FFFFFF" backgroundAlpha="0" width="50%" height="100%" buttonMode="true" minWidth="100" mouseDown="rangeWindowMouseHandler(event);" mouseUp="rangeWindowMouseHandler(event);" mouseMove="rangeWindowMouseHandler(event);" />
<mx:Canvas id="rightBox" backgroundColor="#FFFFFF" backgroundAlpha="0.5" width="0%" height="100%" borderColor="#333333" borderThickness="1" borderStyle="solid" borderSides="top left bottom" />
</mx:HDividedBox>
</mx:annotationElements>
使用以下脚本:
private function rangeWindowMouseHandler(event:MouseEvent):void {
if(event.target === centerBox) {
var coords:Object = rangeDragCoordinates;
switch(event.type.toLowerCase()) {
case 'mousedown':
rangeDrag = true;
break;
case 'mouseup':
rangeDrag = false;
break;
case 'mousemove':
if(rangeDrag) {
var xDiff:Number = -(coords.x - event.stageX) * 4.0;
for(var i:Number = 0; i < dividedBox.numDividers; i++) {
dividedBox.moveDivider(i, xDiff);
}
}
break;
}
coords.x = event.stageX;
coords.y = event.stageY;
}
}
问题是,一次只有一个分隔线实际移动。我发现如果我在移动下一个分隔线之前设置大约 50 毫秒的超时,那么两个分隔线都会移动。然而,这似乎是一种相当尴尬的方法,而且很容易出错。
有人知道是否可以同时移动 HDividedBox 中的两个分隔板,还是我应该采取另一种方法?
I'm trying to have a minimap display with a draggable viewport below a chart. I essentially have this to control the viewport of the chart:
<mx:annotationElements>
<mx:HDividedBox id="dividedBox" horizontalScrollPolicy="off" width="100%" height="100%" liveDragging="true" borderSides="bottom top">
<mx:Canvas id="leftBox" backgroundColor="#FFFFFF" backgroundAlpha="0.5" width="50%" height="100%" borderColor="#333333" borderThickness="1" borderStyle="solid" borderSides="top right bottom" />
<mx:Canvas id="centerBox" backgroundColor="#FFFFFF" backgroundAlpha="0" width="50%" height="100%" buttonMode="true" minWidth="100" mouseDown="rangeWindowMouseHandler(event);" mouseUp="rangeWindowMouseHandler(event);" mouseMove="rangeWindowMouseHandler(event);" />
<mx:Canvas id="rightBox" backgroundColor="#FFFFFF" backgroundAlpha="0.5" width="0%" height="100%" borderColor="#333333" borderThickness="1" borderStyle="solid" borderSides="top left bottom" />
</mx:HDividedBox>
</mx:annotationElements>
With the following script:
private function rangeWindowMouseHandler(event:MouseEvent):void {
if(event.target === centerBox) {
var coords:Object = rangeDragCoordinates;
switch(event.type.toLowerCase()) {
case 'mousedown':
rangeDrag = true;
break;
case 'mouseup':
rangeDrag = false;
break;
case 'mousemove':
if(rangeDrag) {
var xDiff:Number = -(coords.x - event.stageX) * 4.0;
for(var i:Number = 0; i < dividedBox.numDividers; i++) {
dividedBox.moveDivider(i, xDiff);
}
}
break;
}
coords.x = event.stageX;
coords.y = event.stageY;
}
}
Problem is, only one divider actually moves at a time. I found that if I set a timeout of about 50ms before moving the next divider that both dividers move. However, this seems like a rather awkward way to approach this and is error prone.
Anyone know if it's possible to move two dividers in a HDividedBox simultaneously or should I be taking another approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最终需要使用 callLater 调用其他分隔符上的更新,而不是立即调用它。
Ended up needing to call the updates on the other divider(s) using callLater rather than calling it immediately.