| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
#1 |
|
Registered User
Join Date: Jun 2006
Posts: 2
|
Hi,
I am trying to use the dragmanager with an element, but at the same time support onClick to allow the element to be selected. I'm not sure if this is flex2 specific (but am using the latest version) in the attributes of the object I have put: click="clickHandler(event)"and inside the script block I have defined the following functions: public function clickHandler(event:MouseEvent):void {This works after a fashion, as the mouseclick gets caught, and on mousedown the canvas gets dragged around. However does anyone know how I can make sure the dragThumbnail method does not start in the case of a mouseclick?parentApplication.setSelectedPhone(this);} The problem is that the drag action always starts (even on a regular mouseclick). I was thinking of making a timer which polls or something but that seems like hacking to me. Anyone have any thoughts? cheers, joris |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Jun 2006
Posts: 2
|
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);
}
(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 |
|
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| as2 and double click / drag detection | huwn | ActionScript 2.0 | 7 | 06-19-2007 05:36 PM |
| combine button double click with drag function | ahungryghost | ActionScript 2.0 | 2 | 01-27-2006 05:35 AM |
| Click & Drag dosent work after a new scene has been added!! | DanielHusk | ActionScript 2.0 | 0 | 04-08-2004 07:30 AM |
| click or drag // menus ???? | Motion2082 | Other Flash General Questions | 2 | 09-08-2003 05:12 PM |
| Help needed in Click & drag | jtb_india | Animation and Effects | 4 | 04-18-2002 11:03 AM |