Friday, April 2, 2010

Drag & Drop WITH keystrokes while...

Is it possible to handle keystrokes WHILE dragging?

I found this to be impossible, because hitting a key always fires an ''onRelease'' or ''onReleaseOutside'' event on the dragged movieclip when releasing the key - intterupting the drag operation.

What I want to do is something like this:

Drag and Drop a Movieclip and while dragging it I want to be able to flip?it with a keystroke.

I tried a LOT of things like disabling focus on the dragged movieclip by doing Selection.setFocus(null) or putting the focus on another object and much more.

This really impedes a lot of UI functionality...

Drag %26 Drop WITH keystrokes while...

I don't know if this will work or not, but I may try the following:

OnMouseDown - startDrag and remove all event listeners from the object - init a keypress listener on the stage, and set a boolean to tell you the object is being dragged

That way, the object you are dragging is not listening for anything

Drag %26 Drop WITH keystrokes while...

Thanks for the advice!

Btw. I found out that this all was after all an issue with the Flash IDE receiving keystrokes and removing focus from the flash movie I was testing. I still wonder why this only happened on my current flash movie.

I tried to reconstruct this with another flash movie but that worked correct.

Well I will have to test this dragging+keystroke stuff outside the Flash IDE which is a bit annoying, but there it works!

There seem to be some issues anyway. I'm working on a multiplayer application and when I test it, the flash running in the Flash IDE actually ''ripps'' the complete application focus to itself when it receives messages from the other application that outputs a trace in the output window. Everything which causes a traces seems to rip the focus from whatever is running completely to the Flash IDE. But I would prefer a more ''silent'' way of logging. I still want to see the trace output, but Flash should leave the focus alone.

But this is not always the case. Sometimes Flash actually ''behaves''. I wonder if there is an option to turn off the ''attention deficit hyperactivity disorder'' of Flash in that case or what is causing it.

No comments:

Post a Comment