FORUMS: list search recent posts

Flash drag and drop hitTest - need to distinguish between two close targets

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Graham Quince
Flash drag and drop hitTest - need to distinguish between two close targets
on Aug 15, 2006 at 10:11:53 am

Hi guys

I'm trying to build a self marking drag and drop exercise for students at the school where I work.

I've created a set of targets and a number of dragable movie clips and am using hitTest to score when an MC is placed correctly on the right target. I have the MCs detect the hitTest and count only the correct targets.

I'm encountering two problems:

1) Sometimes Flash seems to lose the knowledge it's dragging an MC, so when dropped, a score isn't added.

2) An MC when hovering over two targets can stay, it still counts as a correct hit. Can I build in some sort of cancelling out hitTest?

Graham

http://www.quinceweb.com - web design
--------
http://www.shiveringcactus.bravehost.com - Free FX for amateur films


Return to posts index

Matt Klundt
Re: Flash drag and drop hitTest - need to distinguish between two close targets
on Aug 15, 2006 at 2:09:28 pm

1. I don't understand how Flash forgets it is dragging. When do you call stopDrag? This is the one time to call your hitTest.

2. Use a point (centerpoint?) of one of the two objects to have a per pixel test of which object is hit. Such as (this code would be on the frame this occurs in):

mcDrag.onRelease = function() {
    this.stopDrag();
    if (this.hitTest(target1._x, target1._y, true)) {
        this._parent.score++;
    }
    if (this.hitTest(target2._x, target2._y, true)) {
        this._parent.score++;
    }
}

Matt
--------------------
http://www.mcquillendesign.com
http://www.mattfoxgames.com


Return to posts index

Graham Quince
Re: Flash drag and drop hitTest - need to distinguish between two close targets
on Aug 16, 2006 at 10:01:54 am

Thanks for your help Matt. Your code is almost identical to mine. I tried that and also reduced the drag targets. Problem solved. I think the problem has been when two draggable MCs were on top of each other.

Graham

http://www.quinceweb.com - web design
--------
http://www.shiveringcactus.bravehost.com - Free FX for amateur films


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]