Referring to "this" in Dart JS interop Referring to "this" in Dart JS interop dart dart

Referring to "this" in Dart JS interop


You can capture the Js this with JsFunction.withThis(f). With that definition an additionnal argument will be added as first argument. Thus your code should be :

import 'dart:js';class HelloWorldScene {  HelloWorldScene() {    var sceneCollectionJS =        new JsObject.jsify({"onEnter": new JsFunction.withThis(_onEnter)});    context["HelloWorldScene"] =        context["cc"]["Scene"].callMethod("extend", [sceneCollectionJS]);  }  void _onEnter(jsThis) {    jsThis.callMethod("_super");  }}