openfl.events.TouchEvent has no field getTouch

I am using openfl 9.4.1 Lime 8.2.2.

I wrote
“private function onTouchMove(e:TouchEvent):Void {”
“var touch:Touch = e.getTouch(stage);”

But when I compile it with openfl test neko, I get an error at the part

“var touch:Touch = e.getTouch(stage);”
—openfl.events.TouchEvent has no field getTouch—

What do I need to do to resolve this error?

I would appreciate any wisdom you can give me.

I looks like you may be mixing up OpenFL APIs and Starling APIs. Starling’s TouchEvent class has a getTouch() method that works that way. However, OpenFL’s TouchEvent class does not. While many parts of OpenFL and Starling have identical or very similar APIs, this is one place where the difference is a bit more pronounced.

This chapter from the OpenFL Developer’s Guide might help:

And the TouchEvent class in the OpenFL API Reference: