Is startDrag() implemented on neko?

I have a DisplayObject.startDrag() method in a MouseEvent.MOUSE_DOWN listener that works on android, mac and html5 but crashes on neko.

Here’s the error:

openfl test neko
Invalid call
Called from Game.hx line 59
Called from openfl/_v2/events/EventDispatcher.hx line 98
Called from a C function
Called from openfl/_v2/display/DisplayObject.hx line 244
Called from openfl/_v2/display/Stage.hx line 912
Called from openfl/_v2/display/Stage.hx line 387

Is the target object typed as a DisplayObject or Sprite, or is it Dynamic, somehow? Neko explodes at times when it does not know the actual type of the target object, even though you are referencing a valid property or method

1 Like

You got it!

I was using and target is an inherited property of Event and is Dynamic


So how did you fix this?

var character : Sprite;

public function startDragCharacter( e : MouseEvent )
		character =;
		stage.addEventListener( MouseEvent.MOUSE_UP , stopDragCharacter );

whereas previously it was more like:

public function startDragCharacter( e : MouseEvent )
	{; // doesn't work on neko due to the function call on a Dynamic object.
		stage.addEventListener( MouseEvent.MOUSE_UP , stopDragCharacter );

I don’t see any practical difference, but I’ll take your word for it that it works :slight_smile:

In the latter, “” is typed as Dynamic, since Neko doesn’t know that it’s a Sprite, it doesn’t find the inherited method :confused:

more simply:

cast( , DisplayObject ).startDrag();

A Dynamic is a dynamic object that can have 0 or more methods and 0 or more properties assigned to it at runtime.

I’m guessing that the neko runtime has its own dynamic object (or just uses a map instead) and it doesn’t support methods (or certain types of methods). Am I close?

Yeah, I think Neko VM has a lookup table for shared methods and properties, and unless it knows the type at runtime it fails to look it up. Something like that