March 17th, 2009

I have found 2 issues with DragManager.doDrag. One of the problem is just on Mac and second one is “not really problem”, but strange behavior between web version and AIR version. I really can’t find answers for this problems, so I’m trying to get answers from you. I hope anyone has workaround for me
So, first problem is about dragImage alpha problem on Mac. Imagine this: I want drag some button and I want to make dragImage (which is “screenshot” of that dragged button) transparent. So i have create Bitmap from that button and use it as 4th parameter of doDrag() function.
DragManager.doDrag(this, dragSource, event, dragImage, draggedButton.x, draggedButton.y, 0.5, false);
Problem is that on PC dragImage is transparent, but on Mac is solid. And problem is just in AIR, not in web version (Flex). You can try it here
Try drag any button and you should experience this: web version works for PC and Mac as well (I don’t have Linux, so you can try Linux as well), but AIR version works just for PC. DragImage on Mac will be solid and not transparent.
Does anyone know, if this is bug, or there is some workaround for this?
Second issue I have found is somethin strange. As I’m listening from dragStart on Canvas and it handles all 3 buttons, I need to set offset to doDrag() function (5th, 6th parameter) from dragged buton. And you know what? There is difference between web version (Flex) and desktop version (AIR). In web version I need to insert offset like -draggedButton.x, -draggedButton.y, but in AIR version I need to insert draggedButton.x, draggedButton.y. Really strange, but otherwise it doesnt work as expected.
You can see sources of both projects. For web version, use right click, there is View Source and for AIR version use this link for downloading project source: AIR Project Download.
I would be glad to hear your opinions and solutions or workarounds. Thank you
Source for creating screenshot and calling DragManager.doDrag
private function dragStart(event:DragEvent):void
{
var dragSource:DragSource = new DragSource();
var dragImage:Image = new Image();
var bd:BitmapData = new BitmapData(draggedButton.width, draggedButton.height, true, 0x00000000);
bd.draw(draggedButton);
dragImage.source = new Bitmap(bd);
var shadow:DropShadowFilter = new DropShadowFilter(5,225,0x000000,0.5);
var glow:GlowFilter = new GlowFilter(0x888888,0.5,20,20);
glow.inner = true;
dragImage.filters = [shadow, glow];
dragImage.alpha = 0.5;
DragManager.doDrag(this, dragSource, event, dragImage,
draggedButton.x, draggedButton.y, 1, false);
}