I have 2 custom class objects (both MC). I want to check when objA is dragged onto the objB.
Each class constructor defines it name value, so on creation in my document class, if I trace thier names they come out as objA and objB.
In the code for objA, I manage the startDrag and stopDrag:
function toDrag(e$:MouseEvent):void{
this.startDrag(true);
was = new Point(this.x, this.y);
trace("Placing a "+this.name);
}
function toDrop(e$:MouseEvent):void{
if(!this.dropTarget){
dropFail(this);
}
trace(this.name+" Is dropping on "+this.dropTarget.name);
dropFail(this);
}
function dropFail(obj:Sprite):void{
obj.stopDrag();
obj.x = was.x;
obj.y = was.y;
}
[EDIT]: Don’t worry about the dropFail(), as while testing, I want things to move back
When I try this out, this.dropTraget.name comes out as Instance#, instead of objB. Why? I made a click check in objB:
function NameMe($e:MouseEvent):void{
trace("Clicked on "+this.name);
}
This comes back with the right name, but the dropTarget call does not. Again, why?