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 'mous开发者_StackOverflow社区edown':
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?
Ended up needing to call the updates on the other divider(s) using callLater rather than calling it immediately.
精彩评论