Dude, where's my DragOver?

Having it not used for a long time I found out today that AS3 has no DragOver in its MouseEvents. So after a bit of research dugged out several solutions with a custom Event Class but finally resorted to this little if.. statement in my Event Handler for MOUSE_OVER:

//pcont serves as a container for about 100 clips 
//inside that will react to dragOver 
 
//activate on Mousedown immediately
pcont_mc.addEventListener(MouseEvent.MOUSE_DOWN,onDragOver);
pcont_mc.addEventListener(MouseEvent.MOUSE_OVER,onDragOver);

function onDragOver(e:MouseEvent):void
{
  if(e.buttonDown)
   {
     //the Mouse is pressed, 
     //Do something here
   }
}


the buttonDown Property of the MouseEvent makes sure that the Mouse is pressed while you hover your mc.
A more advanced solution can be found at Andre Michelle, he wrote some class files and stuff to adress this shortcoming of Events.

Keine Kommentare:

Kommentar veröffentlichen

You might as well leave a comment on this matter: