ActionScript Drag and Drop Display Objects With Mask And Filter?

Posted by TheDarkIn1978 on Stack Overflow See other posts from Stack Overflow or by TheDarkIn1978
Published on 2010-06-13T04:17:10Z Indexed on 2010/06/13 4:22 UTC
Read the original article Hit count: 364

i've created a sprite to drag and drop around the stage. the sprite is masked and has it's mask as it's child so that it too will drag along with the sprite. everything works fine until i add a drop shadow filter to the sprite. when the drop shadow is added, i can only mousedown to drag and mouseup to drop the sprite if the mouse events occur within the original location of the sprite when it was added to the stage.

how can i fix this problem? could this be an issue with 10.1? if not what am i doing wrong?

var thumbMask:Sprite = new Sprite();
thumbMask.graphics.beginFill(0, 1);
thumbMask.graphics.drawRoundRect(0, 0, 100, 75, 25, 25);
thumbMask.graphics.endFill();

var thumb:Sprite = new Sprite();
thumb.graphics.beginFill(0x0000FF, 1);
thumb.graphics.drawRect(0, 0, 100, 75);
thumb.graphics.endFill();

thumb.addEventListener(MouseEvent.MOUSE_DOWN, drag);
thumb.addEventListener(MouseEvent.MOUSE_UP, drop);

thumb.filters = [new DropShadowFilter(0, 0, 0, 1, 20, 20, 1.0, 3)];

thumb.addChild(thumbMask);
thumb.mask = thumbMask;
addChild(thumb)

function drag(evt:MouseEvent):void
    {
    evt.target.startDrag();
    trace("drag");
    }

function drop(evt:MouseEvent):void
    {
    evt.target.stopDrag();
    trace("drop");
    }

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about drag-and-drop