それは私がほんの数週間前に同じことに苦労)=明らかではありません。
リスト:
<List>
<mouseDown>onListMouseDown(event)</mouseDown>
</Tree>
マウスダウンハンドラ:これは私の解決策だったユーザーがリストの項目をクリックしたときに、ドラッグを開始します
private function onMouseDown(event : MouseEvent) : void {
var list : List = List(event.currentTarget);
// the data of the clicked row, change the name of the class to your own
var item : MyDataType = MyDataType(list.selectedItem);
var source : DragSource = new DragSource();
// MyAwsomeDragFormat is the key that you will retrieve the data by in the
// component that handles the drop
source.addData(item, "MyAwsomeDragFormat");
// this is the component that will be shown as the drag proxy image
var dragView : UIComponent = new Image();
// set the source of the image to a bigger version here
dragView.source = getABiggerImage(item);
// get hold of the renderer of the clicked row, to use as the drag initiator
var rowRenderer : UIComponent = UIComponent(list.indexToItemRenderer(list.selectedIndex));
DragManager.doDrag(
rowRenderer,
source,
event,
dragView
);
}
。 dragEnabled
と他のドラッグ関連のプロパティはリストに設定されていないことに注意してください。
イベントハンドラの先頭にこれを追加すると便利です。
if (event.target is ScrollThumb || event.target is Button) {
return;
}
ただ、ショートにユーザーがスクロールバーのどこかをクリックした場合。それはあまりエレガントではありませんが、それは仕事をします。
dragViewは幅と高さを設定する必要があります:) – jason