Ives tried many hit detections and none of them seem to work for me. I've tried hittest hittestobject hitarea. When my object (which is a or b movie-clip goes fully into c movie clip i want c to move 300 x direction. Does not need to be pin point detection just as long as its in the c movie-clip it works.
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.media.Sound;
import flash.ui.Mouse;
public class bakingCake extends MovieClip {
public function bakingCake() {
// constructor code
var object:MovieClip = new MovieClip;
a.addEventListener(MouseEvent.MOUSE_DOWN,objectA);
b.addEventListener(MouseEvent.MOUSE_DOWN,objectB);
if (object.hitArea(c) == true)
{
c.x = 300;
}
function objectA():void
{
object = a;
object.addEventListener(MouseEvent.MOUSE_OVER,objectFun);
}
function objectB():void
{
object = b;
object.addEventListener(MouseEvent.MOUSE_OVER,objectFun);
}
function objectFun(event:MouseEvent):void
{
object.addEventListener(MouseEvent.MOUSE_DOWN,drag);
object.addEventListener(MouseEvent.MOUSE_UP,sDrag);
}
function drag(event:MouseEvent):void
{
object.startDrag();
}
function sDrag(event:MouseEvent):void
{
object.stopDrag();
}
}
}
}
Did you tried getBounds() ?
I suggest condition:
if (c.getBounds(c.parent).containsRect(a.getBounds(c.parent))
|| c.getBounds(c.parent).containsRect(b.getBounds(c.parent))) {
c.x = 300;
}
IMO the best way is check it triggered by ENTER_FRAME event, atached for any of object.