PDA

View Full Version : dropTarget



kiosk77
May 13th, 2007, 07:35 PM
The following method lives in a class called View which extends Sprite, I'm trying to call a method after the clip is drag on top of another View. But I can't call any methods on dropTarget (which I think its the View that I'm dragging on top of ) what am I doing wroing? thank you in advance.




private function endDrag( evt:MouseEvent ):void {
evt.stopPropagation();
stopDrag();
if ( dropTarget ) {
x = 0; y = 0;
trace( dropTarget.someMethod);
}
if ( owner ) owner.update();
}

senocular
May 13th, 2007, 08:09 PM
are you not getting droptarget at all? Can you trace that and see what reference its providing? Also, looking at your code, I'm guessing its possible that in moving that object by changing its x and y might also change the value of droptarget.

Dazzer
May 13th, 2007, 08:18 PM
droptarget has to belong to something, no?

In this case it should be:

evt.target.droptarget


no?

senocular
May 13th, 2007, 08:19 PM
droptarget is a property of sprite so assuming this code is in his View class or some other subclass of sprite, it should reference that object's droptarget

kiosk77
May 14th, 2007, 02:36 PM
tracing dropTarget I get the Sprite, but I want View which extends Sprite

trace( dropTarget ); // traces Sprite
trace( dropTarget as View ); // traces null

dropTarget.stage gets the the stage.. but how do I access methods in View?

senocular
May 14th, 2007, 02:41 PM
dropTarget is not getting a view, its getting a sprite. You cant use View actions off that instance since its not a view. Are you sure you're dropping on a view (it doesnt seem so according to your traces)

kiosk77
May 14th, 2007, 03:06 PM
Senocular,

thank you for asking the right questions :)

in my View, which extends Sprite... I'm creating another Sprite to draw some graphics. When I'm requesting dropTarget, it is this Sprite that it is being return.

So I have to say, dropTarget.parent to get View

Thank you.