Uncategorized
Flex 2 Drag Manager isDragging Problem
I have been working on a project where I get to enjoy using the Drag and Drop features of flex 2. I started my learning by playing around a little bit with having two list controls that I could drag stuff back and forth with. Then I created my own drag and drop enabled controls. Well really i just used the one in the documentation, but I “felt” like I built my own.
Then I started playing with my real goal. Using contents from a HorizontalList control and dragging those onto a custom component. This was actually very simple. All I had to do was tell my HorizontalList to be dragEnabled=”true”. For the drop portion of the adventure i just implemented dragEnter and dragDrop event handlers on my custom component.
My problem came with this. I have other events like rollOver that fire when an item is dragged over them. And I need to know if something is being dragged so I can have them not fire off. Luckily the DragManager class as a boolean property called “isDragging”. From the docs “Read-only property that returns true if a drag is in progress.” Hurray! That sounds like exactly what I needed. So i added that to my event listener and ran my code again. Of course I was shocked to see that my code ran even though i was dragging items around. So I added a label and I bound it to the DragManager.isDragging and ran my app one more time. No matter what I do that is always false.
So here it is. What do I have to do to make DragManager.isDragging be true? Its a read-only property so something has to enable it. What is it that I am missing.
As it stands I just added an isDragging property to my ModelLocator so that I can continue with the project. But I am very curious what causes this property to be true.
08 Dec 2006 Simeon

The isDragging property is not set up for data binding, so your label won’t update itself when the value of this property changes. Data binding with read-only properties turns out to be a tricky topic, which I’m going to post about on my blog as soon as I’ve finished writing the article.
I don’t have an answer to your drag/drop conundrum, but you might want to try polling the value of DragManager.isDragging using a Timer instead.
Thanks steven. For now I am ok because I am just doing it on my own. The reason I resorted to watching it via binding was that it was false when I was dragging and a rollover event occurred.
I will give the timer a try when I get sec. My wife appears to be going into labor so it might be a couple days
Simeon: You’re welcome. I’ve posted the article I mentioned on my blog if you’re interested: http://dynamicflash.com/2006/12/databinding-to-read-only-properties-in-flex-2/.
I’m stoked to hear your wife is having a baby, but if she’s going into labour then you shouldn’t be reading this ;o) Good luck man!
I don’t know if ive just been lucky or because i’m using Flex 2.0.1 but after spending hours
debugging my code i realsised I was have the same issue, when draging a component
over another component that already had a rollover event.
for me placing the DragingManager.isDragging inside my rollover handler fixed my issue.
onRollOver(e:MouseEvent) : void {
if (!DragingManager.isDragging) {
this.currentState = ‘rollover’;
}
}
so thanks for the advice.