on mouse down, you could add a listener to stage to MOUSE_UP event, so you
can be notified when the user releases the mouse. If I understood your
problem correctly, that should work.
best,
andrei

On Sat, Jul 11, 2009 at 3:56 PM, Alexander Farber <
[email protected]> wrote:

> Good day,
>
> I have a class representing draggable playing cards:
>
>        public dynamic class Card extends Sprite {
>                public function Card() {
>                        ........
>                        addEventListener(MouseEvent.MOUSE_DOWN, handleDown);
>                        addEventListener(MouseEvent.MOUSE_UP, handleUp);
>                        //addEventListener(MouseEvent.MOUSE_OUT, handleOut);
>                }
>                private function handleDown(event:MouseEvent):void {
>                        dispatchEvent(new CardEvent(CardEvent.CLICKED,
> this));
>                        filters = SHADOW;
>                        scaleX = scaleY = 1.2;
>                        startDrag();
>                        addEventListener(MouseEvent.MOUSE_MOVE, handleDrag);
>                        // here some code to store the original card
> coordinates
>                }
>                private function handleUp(event:MouseEvent):void {
>                        filters = null;
>                        scaleX = scaleY = 1;
>                        stopDrag();
>                        removeEventListener(MouseEvent.MOUSE_MOVE,
> handleDrag);
>                        dispatchEvent(new CardEvent(CardEvent.PLAYED,
> this));
>                        // restore the original card coordinates, i.e.
> put it back
>                }
>
> My problem is: I have 3 player avatars + some GUI at the top.
>
> And when a card is being dragged underneath them and
> the mouse button released, then the card object won't
> receive the MOUSE_UP event and thus will stay "up" -
> i.e. stay big (scaleX/Y = 1.2) and have shadow filter.
>
> Does anybody have a solution for this probably frequent
> occuring problem? I've tried adding this method:
>
>                private function handleOut(event:MouseEvent):void {
>                        // if this card is being dragged, release it
>                        if (hasEventListener(MouseEvent.MOUSE_MOVE))
>                                handleUp(event);
>                }
>
> But this will make the cards behaviour even more annoying
> (cards will jump back whenever they touch the GUI...)
>
> I just want to do something, so that handleUp() for
> the dragged card is called just anywhere at the stage
>
> Regards
> Alex
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to