我必须从Flex Tree自定义拖动。为此,我重写了受保护的函数mouseDownHandler
:
override protected function mouseDownHandler(event:MouseEvent):void
{
if ( event.target is ScrollThumb || event.target is Button )
{
return;
}
super.mouseDownHandler(event);
var tree:Tree = Tree(event.currentTarget);
if (tree.selectedItem && tree.indexToItemRenderer(tree.selectedIndex) && tree.selectedItem is Image)
{
var image:Image = Image(tree.selectedItem);
var source:DragSource = new DragSource();
var dragView:Image = new Image();
dragView.source = drawGhost(image);
var dragInitiator:UIComponent = UIComponent(tree.indexToItemRenderer(tree.selectedIndex));
var ghostOffset:Point = dragInitiator.globalToLocal(new Point(event.stageX, event.stageY));
DragManager.doDrag(dragInitiator, source, event, dragView, ghostOffset.x, ghostOffset.y, 1);
}
}
private function drawGhost(image:Image):Bitmap
{
var ghostWidth:int = image.source.width;
var ghostHeight:int = image.source.height;
var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xFF0000, 0.5);
sprite.graphics.drawRect(0, 0, ghostWidth, ghostHeight);
sprite.graphics.endFill();
var bitmapData:BitmapData = new BitmapData(sprite.width, sprite.height, false);
bitmapData.draw(sprite);
var bitmap:Bitmap = new Bitmap(bitmapData);
return bitmap;
}
但我遇到了两个问题:
渐变透明度示例:
答案 0 :(得分:0)
您可以通过将verticalScrollPolicy
设置为“关闭”来禁用垂直滚动。
关于“Gradient”-thing:尝试更改光标以在DragManager中拖动到某个自定义类。