flash as3 - prevent object from being used as dropTarget

695 Views Asked by At

Is there a way to prevent a flash movieclip (or its children) from being used as a dropTarget? I have objects on the stage which are getting in the way of my determining the underlying stage object where a draggable item is being dropped.

2

There are 2 best solutions below

0
sanchez On

There is no way to prevent a flash movieclip (or its children) from being used as a dropTarget.

You could control it from the other end:

function onMouseUp( e:MouseEvent ):void 
{
   var obj = evt.target;
   var target = obj.dropTarget;

   if( target != nonDropAreaMovieClip )
   {
        obj.stopDrag();
   }
}

or if you want the obj to be actually dropped to the backgroundMovieClip, which is behind the nonDropAreaMovieClip, you could calculate the global/local coorinates and just do:

function onMouseUp( e:MouseEvent ):void 
{
   var obj = evt.target;
   var target = obj.dropTarget;

   if( target != nonDropAreaMovieClip )
   {
        obj.stopDrag();
        obj.x = //calculated x
        obj.y = //calculated y
        backgroundMovieClip.addChild( obj );
   }
}
0
TSage On

I've worked around a similar issue by creating movieclips that are transparent and placing them over the drop regions, or by creating a layer with a transparent object as the topmost layer to prevent the children (in the movieclip) from becoming the dropTarget.