如图所示,假设item1的List1拖动到项目iv的List2,我希望项目iv检测拖过状态和高光本身,那么如何实现呢?
答案 0 :(得分:1)
将MouseEvent.MOUSE_OVER
侦听器附加到每个列表元素,检查是否拖动任何内容,如果是,则event.target
会突出显示。
答案 1 :(得分:0)
这是我的解决方案和代码: 对于 List2 :
<s:List
itemRenderer="components.MyRenderer"
dragEnter="myDragEnterHandler(event)"
dragOver="myDragOverHandler(event)"
dragExit="myDragExitHandler(event)">
<fx:Script>
<![CDATA[
private function myDragEnterHandler(event:DragEvent):void {
//we shoudld make List2 be drop target
DragManager.acceptDragDrop(e.currentTarget as IUIComponent);
}
private function myDragOverHandler(event:DragEvent):void {
var dropIndex:int = calDropIndex(event);
var element:MyRenderer= calDropItem(dropIndex);
//undo highlight if there is last over item
if(lastOverItem) {
lastOverItem.undoHighlight();
}
//remember the last highlight one and highlight it
lastOverItem = element;
element.highlight();
}
private function myDragExitHandler(event:DragEvent):void {
var dropIndex:int = calDropIndex(event);
var element:MyRenderer= calDropItem(dropIndex);
element.undoHighlight();
}
private function calDropIndex(event:DragEvent):int {
var dropLocation:DropLocation =
event.currentTarget.layout.calculateDropLocation(event);
var dropIndex:int = dropLocation.dropIndex;
return dropIndex;
}
private function calDropItem(dropIndex:int):MyRenderer{
var element:IVisualElement;
if (layout.useVirtualLayout) {
element = layout.target.getVirtualElementAt(dropIndex);
} else {
element = layout.target.getElementAt(dropIndex);
}
return element as MyRenderer;
}
]]>
</fx:Script>
</S:List>