Heya, I managed to figure part of this out:
I'm not 100% sure I won't run into synchronisation issues with the mouseUpHandler and the timerEventHandler interfering with one another, perhaps someone can give me some advice on it.
Code:
private var timer:Timer;
private var mouseDownEvent:MouseEvent;
public function clickHandler(event:MouseEvent):void
{
parentApplication.setSelectedPhone(this);
// this is a click (so shouldn't be a drag)
}
public function mouseDownHandler(event:MouseEvent):void {
if (timer != null && timer.running) {
// timer was already running, we reset it
timer.stop();
timer.removeEventListener("timerComplete", dragThumbnail);
timer.reset();
}
timer = new Timer(100, 1);
timer.addEventListener("timerComplete", dragThumbnail);
timer.start()
mouseDownEvent = event;
}
public function mouseUpHandler(event:MouseEvent):void {
if (timer.running) {
timer.stop();
timer.removeEventListener("timerComplete", dragThumbnail);
}
}
public function dragThumbnail(timer:TimerEvent):void {
var ds:DragSource = new DragSource();
ds.addData(this, dragType);
DragManager.doDrag(IUIComponent(this), ds, mouseDownEvent);
DragManager.showFeedback(DragManager.MOVE);
}
There is an additional issue, which I think is listed in the flash 9 known bug list: if the mouse does not move, the DragManager will be in a weird state.
(so click, hold, release will actually result in a dragComplete but not a dragDrop.) As I had used an online example that implemented 'to remove the element from a list, drag it outside of the area' which actually uses dragComplete, this now fires if the mouse has not moved. (so click, hold, release causes the element under the mouse to go away).
Does anyone know a workaround for that bug? (if i'm not being clear I can try to make a code example for it)
cheers,
joris