I use JsInterop to map
Kinetic.js I created the following interfaces:
@JsType(prototype = "$wnd.Kinetic.Node")
public interface KNode {
}
@JsType(prototype = "$wnd.Kinetic.Container")
public interface KContainer extends KNode {
/**
* Add a node to this container.
* @param child A child node
*/
public void add(KNode child);
}
@JsType(prototype = "$wnd.Kinetic.Stage")
public interface KStage extends KContainer {
public static abstract class Statics {
public static native KStage create(Element stageContainer, int stageWidth, int stageHeight) /*-{
return new $wnd.Kinetic.Stage({
container : stageContainer,
width : stageWidth,
height : stageHeight
});
}-*/;
}
}
@JsType(prototype = "$wnd.Kinetic.Layer")
public interface KLayer extends KContainer {
public static abstract class Statics {
public static native KLayer create() /*-{
return new $wnd.Kinetic.Layer();
}-*/;
}
}
In my Java class I call:
KStage stage = KStage.Statics.create(stageContainer, stageWidth, stageHeight);
KLayer baseLayer = KLayer.Statics.create();
stage.add(baseLayer);
Running in SDM I get the following error in the last line (stage.add(..)):
SEVERE: (TypeError) : 'undefined' is not a function (evaluating 'this.stage_0_g$.add_219_g$(this.baseLayer_0_g$)')com.google.gwt.core.client.JavaScriptException: (TypeError) : 'undefined' is not a function (evaluating 'this.stage_0_g$.add_219_g$(this.baseLayer_0_g$)')
at Unknown.wrap_4_g$(Unknown Source)
at Unknown.entry0_0_g$(Unknown Source)
at Unknown.anonymous(Unknown Source)
Did I miss something here?